Notice
Recent Posts
Recent Comments
Link
반응형
«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
Archives
Today
Total
관리 메뉴

To Be Develop

from seleniumwebdrivercommonactionchains import ActionChains 본문

study

from seleniumwebdrivercommonactionchains import ActionChains

To Be Develop 2024. 11. 29. 00:31
반응형

try:
chrome_driver = self.controller.chrome_driver
print("current_url: ", chrome_driver.current_url)
input("Press Enter key to continue...")
chrome_driver.switch_to.default_content()
print("Complete switch to default content")

reCAPTCHA iframe 찾기

frames = chrome_driver.find_elements(By.TAG_NAME, "iframe")
input("Press Enter key to continue...")
recaptcha_iframe = None
for frame in frames:
if "reCAPTCHA" in frame.get_attribute("title"):
recaptcha_iframe = frame
break
input("Press Enter key to continue...")
if recaptcha_iframe:

reCAPTCHA iframe으로 전환

chrome_driver.switch_to.frame(recaptcha_iframe)
print("Complete switch to reCAPTCHA iframe")
input("Press Enter key to continue...")
checkbox = WebDriverWait(chrome_driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.recaptcha-checkbox-border")))
actions = ActionChains(chrome_driver)
user_input = input("Do you want to click the checkbox? (Y/N): ")
if user_input.lower() == "y":
actions.move_to_element(checkbox).pause(random.uniform(1, 3)).click().perform()
else:
print("You didn't click the checkbox")
else:
print("No reCAPTCHA")

chrome_driver.switch_to.default_content()

except Exception as e:
print("\n\nNo reCAPTCHA\n\n")

반응형