标签: selenium-chromedriver

使用Selenium的Chrome驱动程序错误:无法发现打开的页面

我在运行Selenium测试时遇到了与Chrome驱动程序相关的错误.错误消息是" 无法发现打开的页面. "Selenium测试一直运行到昨晚.问题似乎是在前一天重新启动服务器后开始的.我无法在本地方框上重现此错误.从服务器上的命令行运行Selenium测试会打开Chrome浏览器,但会导致相同的错误.有任何想法吗?

失败的行:

chromeDriver = new OpenQA.Selenium.Chrome.ChromeDriver(externalDriverPath);
Run Code Online (Sandbox Code Playgroud)

错误消息和堆栈跟踪:

在OpenQA.Selenium.Remium.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary)的OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(响应errorResponse)中无法发现打开的页面(驱动程序信息:chromedriver = 2.1,platform = Windows NT 6.1 SP1 x86_64)在OpenQA.Selenium.Chlenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory)的OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)上的OpenQA.Selenium.Remote.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities desiredCapabilities)的`2参数) ,ChromeOptions选项)在SeleniumTests.BaseTest.SetupBrowsers()的OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory)

创建ChromeDriver实例时,会出现一个控制台窗口.带错误的服务器似乎引用了未实现的内容.

具有错误的服务器的ChomeDriver输出:

在端口2984上启动ChromeDriver(v2.1)[4700:4292:0108/111503:错误:gpu_info_collector_win.cc(102)]无法检索va盖WinSAT评估.[4700:4292:0108/111503:错误:chrome_views_delegate.cc(176)]未实现[4700:4292:0108/111503:错误:desktop_root_window_host_win.cc(746)] NOT IMPLEMENT ED [0108/111504:错误:gl_surface_egl. cc(132)] eglInitialize失败,错误UNKNO WN [0108/111504:ERROR:gl_surface_win.cc(97)] GLSurfaceEGL :: InitializeOneOff失败.

从我的电脑ChomeDriver输出工作正常:

在端口18786上启动ChromeDriver(v2.1)[884540:883760:0108/114010:错误:gpu_info_collector_win.cc(102)]无法检索有效的WinSAT评估.[884992:884996:0108/114010:错误:base_feature_provider.cc(122)] manifestTypes:一个较慢的web_page上下文需要提供匹配值.[885232:885236:0108/114011:错误:base_feature_provider.cc(122)] manifestTypes:一个较慢的web_page上下文需要提供匹配值.[884540:883760:0108/114011:错误:base_feature_provider.cc(122)] manifestTypes:一个低温的web_page上下文需要为匹配提供一个值.[0108/114011:错误:gl_surface_egl.cc(131)] eglInitialize失败,错误UNKNO WN [0108/114011:错误:gl_surface_win.cc(54)] GLSurfaceEGL :: InitializeOneOff失败.

selenium selenium-chromedriver

28
推荐指数
3
解决办法
4万
查看次数

Python Selenium Chrome Webdriver

我开始自动化无聊的东西书,我正在尝试通过python打开一个chrome web浏览器.我已经安装了硒和

我试过运行这个文件:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

browser = webdriver.Chrome()
browser.get('https://automatetheboringstuff.com')
Run Code Online (Sandbox Code Playgroud)

但正因为如此,我得到这个错误:

Traceback (most recent call last):   File "C:\Program Files
   (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py",
 line 74, in start
     stdout=self.log_file, stderr=self.log_file)   File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in __init__
     restore_signals, start_new_session)   File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, in _execute_child
     startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):   File "C:/Program Files
(x86)/Python36-32/test.py", line 5, in <module>
    browser = …
Run Code Online (Sandbox Code Playgroud)

python selenium selenium-chromedriver

28
推荐指数
2
解决办法
9万
查看次数

使用chromedriver和selenium/python/ubuntu

我正在尝试使用chromedriver执行一些测试,并尝试使用以下方法启动chromedriver.

driver = webdriver.Chrome('/usr/local/bin/chromedriver')
Run Code Online (Sandbox Code Playgroud)

driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver')
Run Code Online (Sandbox Code Playgroud)

import os
from selenium import webdriver

chromedriver = "/usr/local/bin/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get("http://stackoverflow.com")
Run Code Online (Sandbox Code Playgroud)

但这些似乎都没有帮助,错误是: selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.

我已多次检查并且chromedriver位于现场/usr/local/bin.

我的脚本仍然无效.任何身体都可以帮助.

我的google-chrome位置是:/ usr/bin/google-chrome

python selenium selenium-chromedriver selenium-webdriver

27
推荐指数
3
解决办法
5万
查看次数

使用Selenium Python和chromedriver截取整页的屏幕截图

尝试了各种方法之后......我偶然发现这个页面采用了chromedriver,selenium和python的全页截图.

原始代码在这里:http://seleniumpythonqa.blogspot.com/2015/08/generate-full-page-screenshot-in-chrome.html(我在下面的帖子中复制代码)

它使用PIL,效果很棒!!!!! 然而,有一个问题......它捕获整个页面的固定标题和重复,并且在页面更改期间也错过了页面的某些部分.示例网址截取屏幕截图:

http://www.w3schools.com/js/default.asp

如何避免使用此代码重复标头...或者是否有更好的选项只使用python ... (我不知道java,不想使用java).

请参阅下面的当前结果和示例代码的屏幕截图.

带有重复标题的整页截图

test.py

"""
This script uses a simplified version of the one here:
https://snipt.net/restrada/python-selenium-workaround-for-full-page-screenshot-using-chromedriver-2x/

It contains the *crucial* correction added in the comments by Jason Coutu.
"""

import sys

from selenium import webdriver
import unittest

import util

class Test(unittest.TestCase):
    """ Demonstration: Get Chrome to generate fullscreen screenshot """

    def setUp(self):
        self.driver = webdriver.Chrome()

    def tearDown(self):
        self.driver.quit()

    def test_fullpage_screenshot(self):
        ''' Generate document-height screenshot '''
        #url = "http://effbot.org/imagingbook/introduction.htm"
        url = …
Run Code Online (Sandbox Code Playgroud)

python selenium webpage-screenshot selenium-chromedriver

27
推荐指数
13
解决办法
4万
查看次数

Selenium:WebDriverException:Chrome无法启动:由于google-chrome不再运行而崩溃,因此ChromeDriver假设Chrome已崩溃

我知道这个问题有几个答案,但到目前为止我没有任何帮助,所以我发布了一个新问题.

最近我换了电脑,从那时起我不能用硒发射铬.我也试过firefox但浏览器只是没有lanch.

from selenium import webdriver

d = webdriver.Chrome('/home/PycharmProjects/chromedriver')

d.get('https://www.google.nl/')
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /opt/google/chrome/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.43.600233, platform=Linux 4.15.0-38-generic x86_64)
Run Code Online (Sandbox Code Playgroud)

我安装了最新的chrome版本和chromedriver

编辑:尝试@ b0sss解决方案后,我收到以下错误.

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
  (chrome not reachable)
  (The process started from chrome location /opt/google/chrome/google-chrome is no longer running, so chromedriver is …
Run Code Online (Sandbox Code Playgroud)

python selenium google-chrome selenium-chromedriver selenium-webdriver

27
推荐指数
8
解决办法
4万
查看次数

Chromedriver在使用Selenium Grid和.net的特定机器上速度极慢

概述: Chromedriver在一台机器上正常工作,但在另外两台相同的机器上工作速度非常慢.

建立:

  • Selenium Webdriver使用.Net进行编码,使用Selenium Grid进行分发测试.正在Visual Studio 2010中使用MSTest以运行测试.
  • 一台64位Windows 7本地计算机充当集线器
  • 我的本地网络上有三台32位Win 7远程计算机(其中两台是虚拟的)都配置为节点.以下是用于启动远程计算机上的节点的命令:

    java -jar c:\ seleniumWebDriver\seleniumGrid\selenium-server-standalone-2.31.0.jar -role node -hub http://XXX.XXX.XXX.XXX:4444/grid/register -browser"browserName = chrome" ,maxInstances = 4 -Dwebdriver.chrome.driver ="C:\ seleniumWebDriver\chromedriver.exe"

  • 驱动程序在代码中以这样的方式启动:

    DesiredCapabilities capability = new DesiredCapabilities(); capability.SetCapability(CapabilityType.BrowserName,browser); driver = new RemoteWebDriver(new Uri(hubUrl),capability);

  • 上面的变量"browser"和"hubUrl"通过在运行时构建的app.config文件传递.对于这种情况,浏览器= chrome.

问题:

  • 当我使用上面的命令将机器212(它是一个虚拟机)设置为chrome节点,然后从集线器启动脚本时,我在正确的远程机器上看到chrome start并正常运行.它每秒在5-10个命令之间.

  • 当我以相同的方式将机器78(虚拟机)或机器103(真实机器)设置为节点,然后从集线器启动脚本时,我看到节点正确地启动了chrome.但是,它运行速度非常慢,如每秒1次或更少.

其他信息: 就像我说的,在一台机器上镀铬工作正常,但在其他机器上,运行速度非常慢.Firefox和IE配置为节点时,可以正常工作.

我已将机器212(工作正常)与其他机器进行了比较,但无法找到差异.所有机器都使用'selenium-server-standalone-2.31.0.jar'和相同版本的ChromeDriver.

似乎节点机器没有被重载.此外,这是一个非常一致的性能差异,似乎与网络或机器上的任何波动负载无关.

我的网络技术已经验证所有这些机器在网络上配置相同.

以前有人见过这样的事吗?

编辑1:我今天登录,所有三台远程机器都在缓慢运行chrome.在其中一个是正常的之前,但现在他们都很慢.

mstest webdriver selenium-grid selenium-chromedriver selenium-webdriver

25
推荐指数
2
解决办法
2万
查看次数

如何使用Python Selenium Webdriver在chrome中加载默认配置文件?

因此,我想使用pythons webdriver打开其默认配置文件的chrome.我已经尝试了我能找到的所有东西,但我仍然无法让它发挥作用.谢谢您的帮助!

python selenium-chromedriver

25
推荐指数
5
解决办法
3万
查看次数

缺少共享库libgconf-2.so.4

我想在其中一个AWS EC2实例(linux())中安装chromedriverRed Hat Enterprise Linux Server release 6.7 Santiago - 64 bit.在安装chromedriver时,由于缺少包装,我们遇到了问题.我可以在这里找到包裹,但这个实习生需要许多其他包裹.使用任何其他AMI都不是一种选择.

错误是 -

error while loading shared libraries libgconf-2.so.4 cannot open shared object file
Run Code Online (Sandbox Code Playgroud)

linux amazon-ec2 selenium-chromedriver rhel6

25
推荐指数
2
解决办法
4万
查看次数

类型错误:WebDriver.__init__() 获得参数“选项”的多个值

错误是:

TypeError: WebDriver.__init__() got multiple values for argument 'options'
Run Code Online (Sandbox Code Playgroud)

`

代码是:

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

browser = webdriver.Chrome(r'/usr/bin/chromedriver', options=chrome_options)
Run Code Online (Sandbox Code Playgroud)

这是错误:

TypeError                                 Traceback (most recent call last)
<ipython-input-5-9a7e59e392ae> in <cell line: 6>()
      4 chrome_options.add_argument('--headless')
      5 
----> 6 browser = webdriver.Chrome(r'/usr/bin/chromedriver', options=chrome_options)

TypeError: WebDriver.__init__() got multiple values for argument 'options'
Run Code Online (Sandbox Code Playgroud)

python webdriver python-3.x selenium-chromedriver selenium-webdriver

25
推荐指数
1
解决办法
5万
查看次数

如何在静默模式下执行Selenium Chrome WebDriver?

使用Chrome Selenium-WebDriver时,它将在服务器启动时输出诊断输出:

在端口9515上启动ChromeDriver(v2.0)

我不想看到这些消息,我怎么能抑制它们呢?

我这样做

ChromeOptions options = new ChromeOptions();
options.AddArgument("--silent");
IWebDriver Driver = new ChromeDriver(options);
Run Code Online (Sandbox Code Playgroud)

但诊断输出不会被抑制.

c# selenium webdriver selenium-chromedriver selenium-webdriver

24
推荐指数
5
解决办法
3万
查看次数