Skip to content

Instantly share code, notes, and snippets.

self.log("Wait")
driver.implicitly_wait(5)
self.log("Switch")
driver.switch_to.frame(driver.find_elements_by_tag_name("iframe")[0])
driver.switch_to.default_content()
iframes = driver.find_elements_by_tag_name("iframe")
driver.switch_to.frame(iframes[1])
self.wait_between(LONG_MIN_RAND, LONG_MAX_RAND)
capt_btn = WebDriverWait(driver, 50).until(
EC.element_to_be_clickable((By.XPATH ,'//button[@id="solver-button"]'))
)
self.log("Wait")
self.wait_between(LONG_MIN_RAND, LONG_MAX_RAND)
self.log("Find audio button")
audio_btn = WebDriverWait(driver, 50).until(
EC.element_to_be_clickable((By.XPATH ,'//button[@id="recaptcha-audio-button"]'))
)
self.log("Wait")
driver.implicitly_wait(10)
self.log("Click")
check_box.click()
self.log("Wait")
self.wait_between(MIN_RAND, MAX_RAND)
action = ActionChains(driver);
self.human_like_mouse_move(action, check_box)
self.log("Switch")
# Using B-spline for simulate humane like mouse movments
def human_like_mouse_move(self, action, start_element):
points = [[6, 2], [3, 2],[0, 0], [0, 2]];
points = np.array(points)
x = points[:,0]
y = points[:,1]
t = range(len(points))
self.log("Switch to new frame")
driver.switch_to.frame(driver.find_elements_by_tag_name("iframe")[0])
self.log("Wait for recaptcha-anchor")
check_box = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID ,"recaptcha-anchor")))
self.log("Wait")
self.wait_between(MIN_RAND, MAX_RAND)
action = ActionChains(driver);
self.wait_between(MIN_RAND, MAX_RAND) # wait
search_btn = WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.ID ,"submit")))
# Wait again
self.wait_between(MIN_RAND, MAX_RAND)
search_btn.click() # click on submit
self.wait_between(LONG_MIN_RAND, LONG_MAX_RAND) # wait again
def setUpOptions(self):
self.options = webdriver.FirefoxOptions()
self.options.headless = self.headless
phone_input = driver.find_element_by_xpath('//*[@id="mobile-number"]') # find input by xpath
phone_input.send_keys(number) # send number
self.wait_between(MIN_RAND, MAX_RAND) # wait for random seconds