import traceback
from time import sleep
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
width = 1024
height = 768
chrome_options = Options()
chrome_options.page_load_strategy = 'normal'
chrome_options.add_argument('--enable-automation')
chrome_options.add_argument('disable-infobars')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--lang=en')
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('--allow-insecure-localhost')
chrome_options.add_argument('--allow-running-insecure-content')
chrome_options.add_argument('--disable-notifications')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--disable-browser-side-navigation')
chrome_options.add_argument('--mute-audio')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--force-device-scale-factor=1')
chrome_options.add_argument(f'window-size={width}x{height}')
chrome_options.add_experimental_option(
'prefs', {
'intl.accept_languages': 'en,en_US',
'download.prompt_for_download': False,
'download.default_directory': '/dev/null',
'automatic_downloads': 2,
'download_restrictions': 3,
'notifications': 2,
'media_stream': 2,
'media_stream_mic': 2,
'media_stream_camera': 2,
'durable_storage': 2,
}
)
driver = webdriver.Chrome(options=options)
driver.set_page_load_timeout(10) # Timeout 10 seconds
# Polling queue
while True:
url = queue.pop()
# Try open url
try:
driver.get(url)
except BaseException as e:
print(e)
print(traceback.format_exc())
continue
# Take website screenshot
png = driver.get_screenshot_as_png()
# Extract html from iframes (if any)
htmls = [driver.page_source]
iframes = driver.find_elements_by_xpath("//iframe")
for index, iframe in enumerate(iframes):
try:
driver.switch_to.frame(index)
htmls.append(driver.page_source)
driver.switch_to.default_content()
except BaseException as e:
print(e)
print(traceback.format_exc())
continue
# Do some analysis
for html in htmls:
# ...
pass
# Wait a bit
sleep(0.1)
Opening https://www.yourmechanic.com/user/appointment/3732777/?access_token=HLZYIg&ukey=6quWpg1724633&rcode=abttgi&utm_medium=sms&utm_source= rb
LOAD EXCEPTION Message: timeout: Timed out receiving message from renderer: 10.000
(Session info: headless chrome=83.0.4103.116)
Traceback (most recent call last):
File "/Users/macbmacbookpro4ookpro4/Documents/Projects/python/proj001/main.py", line 202, in inference
driver.get(url)
File "/opt/anaconda3/envs/cv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "/opt/anaconda3/envs/cv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/opt/anaconda3/envs/cv/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 10.000
(Session info: headless chrome=83.0.4103.116)
我有一个应用程序,我需要一个长时间运行的Selenium web驱动程序实例(我在无头模式下使用Chrome驱动程序83.0.4103.39)。基本上,应用程序不断地从队列中提取url数据,并将提取的url提供给Selenium,Selenium应该对网站进行一些分析。许多这样的网站可能会关闭,无法访问或中断,所以我设置了10秒的页面加载超时,以避免Selenium永远等待页面加载。 我这里遇到的
我在运行方案时遇到以下错误。 编辑:在DOCKER容器中运行时发生(使用最新的DOCKER图像用于chrome浏览器,并使用node-chrome-debug) 任何想法都将不胜感激。
您好,我在chrome中通过SeleniumWebDriver执行UI测试时遇到以下错误。 81.0.4044.69。 [1586841277.704][严重]:从渲染器接收消息超时:0.100 有人能帮我修一下吗?
另外:在同一行,我得到了另一个错误: OpenQa.Selenium.WebDriverException:对远程WebDriver服务器的URL的HTTP请求在60秒后超时。---->system.net.webexception:操作已在C:\projects\webdriver\dotnet\src\webdriver\remote\httpcommandexecutor.cs:line 1
使用方法加载Url,大约需要4分钟,会引发以下异常 在端口6967上启动ChromeDriver 73.0.3683.68(47787EC04B6E38E22703E856E101E840B65AFE72)只允许本地连接。请保护ChromeDriver和相关测试框架使用的端口,以防止恶意代码访问。2019年4月20日3:59:52 PM org.openqa.selenium.remote.pro