From da29303415adfd3362c105da1f70964b4f83514f Mon Sep 17 00:00:00 2001 From: ibnaleem Date: Thu, 19 Oct 2023 15:12:23 +0100 Subject: [PATCH] fix NoSuchElementException and undetected_chromedriver --- main.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index ab8b060..8ccdd6b 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ from colorama import Fore, init, Style import ctypes, platform, os, time import selenium, requests, webbrowser + from seleniunbase import Driver except ImportError: input("You do not have all of the modules required installed.") @@ -19,7 +20,7 @@ class zefoy: def __init__(self): - self.driver = uc.Chrome() + self.driver = Driver(uc=True) self.captcha_box = '/html/body/div[5]/div[2]/form/div/div' self.clear = "clear" @@ -121,9 +122,15 @@ def send_bot(self, search_button, main_xpath, vid_info, div): time.sleep(3) send_button = f'/html/body/div[{div}]/div/div/div[1]/div/form/button' - self.driver.find_element('xpath', send_button).click() - self.sent += 1 - print(self._print(f"Sent {self.sent} times.")) + try: + + self.driver.find_element('xpath', send_button).click() + self.sent += 1 + print(self._print(f"Sent {self.sent} times.")) + + except selenium.common.exceptions.NoSuchElementException: + self.send_bot(search_button, main_xpath, vid_info, div) # recursively send bot until Element is found; passing the exception stops the bot + time.sleep(4) self.send_bot(search_button, main_xpath, vid_info, div)