Closed gouravkumar99 closed 9 months ago
@gouravkumar99 please provide the full script and expected result//error code
closing due to inactivity
@kaliiiiiiiiii when executing javascript ,the response is None. But Response is coming on normal selenium driver.
import os
import shutil
from selenium_profiles.webdriver import Chrome
from selenium_profiles.profiles import profiles
from selenium_driverless.webdriver import ChromeOptions
from selenium_driverless.types.by import By
try:
shutil.rmtree(os.getcwd() + "/data/profiles/" + str(1) + "/")
except Exception as e:
pass
profile = {"cdp":{"touch":True,"maxtouchpoints":10,"emulation":{"mobile":False,"width":1280,"height":768,"deviceScaleFactor":1,"screenOrientation":{"type":"landscapePrimary","angle":0}},"cores":16,"useragent":{"platform":"Win32","acceptLanguage":"en-US","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36","userAgentMetadata":{"brands":[{"brand":"Not.A/Brand","version":"8"},{"brand":"Chromium","version":"114"},{"brand":"Google Chrome","version":"114"}],"fullVersionList":[{"brand":"Not.A/Brand","version":"8.0.0.0"},{"brand":"Chromium","version":"114.0.5735.199"},{"brand":"Google Chrome","version":"114.0.5735.199"}],"fullVersion":"114.0.5735.199","platform":"Windows","platformVersion":"15.0.0","architecture":"x86","model":"","mobile":False,"bitness":"64","wow64":False}}}}
options = ChromeOptions()
options.add_argument('--blink-settings=imagesEnabled=false')
options.add_argument("--user-data-dir=" + os.getcwd() + "/data/profiles/" + str(1) + "/")
driver = Chrome(profile, options=options, driverless_options=True, injector_options=True)
driver.get('https://smallseotools.com/image-to-text-converter/')
findRecaptchaClientsScript = """
function findRecaptchaClients(){return"undefined"!=typeof ___grecaptcha_cfg?Object.entries(___grecaptcha_cfg.clients).map((([e,c])=>{const t={id:e,version:e>=1e4?"V3":"V2"};return Object.entries(c).filter((([e,c])=>c&&"object"==typeof c)).forEach((([c,n])=>{const i=Object.entries(n).find((([e,c])=>c&&"object"==typeof c&&"sitekey"in c&&"size"in c));if("object"==typeof n&&n instanceof HTMLElement&&"DIV"===n.tagName&&(t.pageurl=n.baseURI),i){const[n,a]=i;t.sitekey=a.sitekey;const s="V2"===t.version?"callback":"promise-callback",l=a[s];if(l){t.function=l;const i=[e,c,n,s].map((e=>`['${e}']`)).join("");t.callback=`___grecaptcha_cfg.clients${i}`}else t.callback=null,t.function=null}})),t})):[]}return findRecaptchaClients();
"""
try:
response = driver.execute_script(findRecaptchaClientsScript)
print(response)
except Exception as e:
print(e)
input("Press ENTER to exit: ")
driver.quit()
@gouravkumar99
This issue might have been resolved by now with the newer versions.
Please make sure to have the latest version of selenium-driverless installed. (pip install --upgrade selenium-driverless
)
if i call JavaScript function so it's not working.
redirect_script = "document.location.href = 'https://mail.google.com/mail/u/0/#inbox';" self.browser.execute_script(redirect_script)