gpt4 book ai didi

python - selenium.common.exceptions.TimeoutException : Message: script timeout: result was not received in 30 seconds

转载 作者:太空宇宙 更新时间:2023-11-03 20:47:13 24 4
gpt4 key购买 nike

我将脚本放在页面上,但出现此错误?

selenium.common.exceptions.TimeoutException: Message: script timeout: result was not received in 30 seconds

driver.set_script_timeout() 没有帮助

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

options = Options()

options.add_argument("start-maximized")
driver = webdriver.Chrome(chrome_options=options)
driver.get("https://www.apple.com/")
driver.set_script_timeout()
driver.execute_async_script("""const script = document.createElement('script'); script.id = '__table_iac'; script.dataset.shortCode = '97sqKm'; script.src = 'https://concierge.table.co/static/widget/inappchat.js';; document.body.appendChild(script);""")
time.sleep(5)

最佳答案

您的异步脚本不会返回任何内容。

Selenium 期望在异步脚本完成后触发回调。如果 30 秒后没有返回任何信息,脚本超时并抛出错误。

不要尝试作为异步脚本运行,而是尝试将其作为标准内联脚本运行。

driver.execute_script("""const script = document.createElement('script'); script.id = '__table_iac'; script.dataset.shortCode = '97sqKm'; script.src = 'https://concierge.table.co/static/widget/inappchat.js';; document.body.appendChild(script);""")

关于python - selenium.common.exceptions.TimeoutException : Message: script timeout: result was not received in 30 seconds,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56508315/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com