Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
428 views
in Technique[技术] by (71.8m points)

python - 硒在尝试重新连接时弹出Chrome页面-Python3(Selenium pop up chrome pages while trying to reconnect - Python3)

So, I have a selenium code in python that stops and wait me finishing the captcha.

(因此,我在python中有一个硒代码,该代码停止并等待我完成验证码。)

The 80 seconds of timeout were insufficient to me, so i found this code online:

(80秒的超时对我来说还不够,所以我在网上找到了以下代码:)

def get_session_data(driver):
    url = driver.command_executor._url
    session_id = driver.session_id

    return url, session_id


driver = webdriver.Chrome(executable_path = '/chromedriver78')
driver.delete_all_cookies()
wait = WebDriverWait(driver, 30)


session_url, session_id = get_session_data(driver)

while True:
            try:
                wait.until(condition)
            except TimeoutException:
                driver = webdriver.Remote(command_executor = session_url, desired_capabilities = {})
                driver.session_id = session_id
            else:
                break

But every time Python does a cycle in the while-true, pops up a chrome page with no link.

(但是每次Python在while-true中执行一个循环时,都会弹出一个没有链接的镶边页面。)

How to avoid this behavior?

(如何避免这种行为?)

  ask by Gianla translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...