kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver
https://kaliiiiiiiiii.github.io/Selenium-Driverless/
Other
412 stars 52 forks source link

switch to frame not work #38

Closed DeltaDarkness closed 10 months ago

DeltaDarkness commented 10 months ago

Capture this line break my code

0xScratch commented 10 months ago

Can you point out the file which you are referring to?

DeltaDarkness commented 10 months ago

i mean

driver.execute_script("")

not work in this lib

kaliiiiiiiiii commented 10 months ago

@DeltaDarkness Please provide

DeltaDarkness commented 10 months ago

Code :

await driver.get('https://probot.io/daily')
                await driver.implicitly_wait(10)
                await asyncio.sleep(3)
                elem3 = await driver.find_element(By.CSS_SELECTOR, "#main > div:nth-child(3) > section > div > div > div:nth-child(1) > div:nth-child(1) > div > div > div > div.onboarding-container > div > button")
                await elem3.click()
                await asyncio.sleep(3)
                elem4 = await driver.find_element(By.CSS_SELECTOR, "#main > div:nth-child(3) > section > div > div > div:nth-child(1) > div.daily-parent > div > div.daily-logo-text")
                await elem4.click()
                await asyncio.sleep(4)
                sitekey = await driver.execute_script("return document.querySelector('body > input[id]').getAttribute('value');")
                print(sitekey)
                api_key = "YOUR_API"
                solver = TwoCaptcha(api_key)
                print("Solving captcha...")
                response = solver.recaptcha(sitekey=sitekey,url=web,)
                print(f'Captcha Key: {response["code"]}')
                driver.execute_script("document.getElementById('g-recaptcha-response').value = '{}';".format(response["code"]))
//////////////////////////////
error :
TypeError: Cannot read properties of null (reading 'getAttribute')
    at <anonymous>:1:75
DeltaDarkness commented 10 months ago
            iframe = await driver.find_element(By.CSS_SELECTOR,"iframe[name^='a-'][src^='https://www.google.com/recaptcha/api2/anchor?']")
            await driver.switch_to.frame(iframe)
kaliiiiiiiiii commented 10 months ago

@DeltaDarkness JavaScript

I am pretty sure the JavaScript Error isn't a bug:) Seems to me more like the elemen't isn't loaded yet or doesn't exist

Iframe

dublicate to https://github.com/kaliiiiiiiiii/Selenium-Driverless/issues/8

This is a warning!

Please ONLY open a issue if there's a bug, and check first if it's a dublicate

If you keep opening arbitary issue, I'll have to restrict you from doing so

DeltaDarkness commented 10 months ago

yes sir i am sorry i will check before do it again thanks for u effort