标签: webdriver

Firefox更新后无法用Selenium打开浏览器

我在Ubuntu Desktop 16.04上使用Selenium WebDriver,我无法打开浏览器.Firefox更新后出现以下错误(在此之前,一切正常):

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    driver = webdriver.Firefox()
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 81, in __init__
    self.binary, timeout)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 98, in _wait_until_connectable
    raise WebDriverException("The browser appears to have exited "
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
Run Code Online (Sandbox Code Playgroud)

browser firefox selenium webdriver

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

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

Selenium WebDriver如何关闭浏览器弹出窗口

我正在使用selenium webDriver为Web应用程序编写测试,并遇到了一个场景,当我尝试关闭浏览器时,我得到一个弹出窗口"你确定吗?页面要求你确认你要离开 - 输入的数据将会迷路了." 有2个按钮:保持页面和保持页面

如何点击这些按钮?

selenium webdriver

36
推荐指数
4
解决办法
7万
查看次数

Jenkins:在Windows上看不到Selenium GUI测试

当我从jenkins(windows)运行我的selenium测试(mvn测试)时,我只看到控制台输出.我没有看到真正的浏览器被打开.如何配置jenkins以便我可以看到运行测试的浏览器?

windows selenium webdriver maven jenkins

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

Selenium WebDriver - 如何使用C#设置页面加载超时

我正在使用Selenium 2.20 WebDriver使用C#创建和管理firefox浏览器.要访问页面,我使用以下代码,在访问URL之前设置驱动程序超时:

driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); // Set implicit wait timeouts to 5 secs
driver.Manage().Timeouts().SetScriptTimeout(new TimeSpan(0, 0, 0, 5));  // Set script timeouts to 5 secs
driver.Navigate().GoToUrl(myUrl);   // Goto page url
Run Code Online (Sandbox Code Playgroud)

问题是有时页面需要永远加载,并且看起来使用selenium WebDriver加载页面的默认超时是30秒,这太长了.我不相信我设置的超时适用于使用GoToUrl()方法加载页面.

所以我试图弄清楚如何设置页面加载的超时,但是,我找不到任何实际工作的属性或方法.当我单击一个元素时,默认的30秒超时似乎也适用.

有没有办法将页面加载超时设置为特定值,以便当我调用GoToUrl()方法时,它只会等待我指定的时间才能继续?

c# selenium timeout webdriver wait

36
推荐指数
3
解决办法
7万
查看次数

是否可以使用Selenium WebDriver来驱动PhantomJS?

我正在阅读Selenium WebDriver的文档,例如它可以驱动Chrome.我在想,"驾驶"PhantomJS会不会更有效率?

有没有办法使用Selenium和PhantomJS?

我的预期用途是网页抓取:我抓的网站加载了AJAX和许多可爱的JavaScript,我认为这个设置可能是我正在使用的Scrapy Python框架的一个很好的替代品.

selenium webdriver web-scraping phantomjs

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

selenium webdriver如何将文件上传到浏览器?

我是一个javascript/java开发人员,我一直在试图弄清楚selenium webdriver自动化框架如何从文件系统上传文件.无法通过javascript设置文件输入,因为它是安全违规.然而,不知何故,webdriver能够使用以下命令执行此操作:

driver.setFileDetector(new LocalFileDetector());
WebElement upload = driver.findElement(By.id("myfile"));
upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
driver.findElement(By.id("submit")).click();
Run Code Online (Sandbox Code Playgroud)

所以他们通过发送密钥来设置价值?我不明白.我查看了此处的源代码:http: //code.google.com/p/selenium/source/checkout 我仍然无法找到他们这样做的地方.

编辑:我的问题不是如何用selenium做这个,但是硒开发人员是如何做到这一点的呢?他们是如何解决javascript中的安全限制的?他们如何上传文件?

selenium automation webdriver browser-automation selenium-chromedriver

35
推荐指数
1
解决办法
4万
查看次数

无法运行量角器 - ECONNREFUSED连接ECONNREFUSED

我正在努力学习AngularJS.作为其中的一部分,我想学习使用端到端测试.目前,我有一个这样的目录结构:

node_modules
  .bin
  ...
  protractor
    ...
    node_modules
       .bin
       adam-zip
       glob
       minijasminenode
       optimist
       saucelabs
       selenium-webdriver
protractor
  config.js
src
  tests
    test.e2e.js
Run Code Online (Sandbox Code Playgroud)

我的config.js文件如下所示:

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',

    capabilities: {
        'browserName': 'chrome'
    },

    specs: [
        '../src/tests/test.e2e.js'
    ],

    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    }
};
Run Code Online (Sandbox Code Playgroud)

test.e2e.js如下所示:

'use strict';

describe('My Sample', function () {
    driver = protractor.getInstance();

    beforeEach(function () {
        driver.get('#/');
    });

    it('My First Test', function () {
        message = "Hello.";
        expect(message).toEqual('World.');
    });
});
Run Code Online (Sandbox Code Playgroud)

当我尝试使用量角器运行我的端到端测试时,我从命令行运行以下命令:

node_modules\.bin\protractor protractor\config.js
Run Code Online (Sandbox Code Playgroud)

当我运行该命令时,我收到以下错误:

C:\Src\MyProject\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1542
      throw error;
            ^
Error: ECONNREFUSED …
Run Code Online (Sandbox Code Playgroud)

debugging webdriver errno angularjs protractor

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

Selenium headless:如何使用 Selenium 绕过 Cloudflare 检测

希望专家能帮助我解开 Selenium/Cloudflare 之谜。我可以让一个网站在普通(非无头)Selenium 中加载,但无论我尝试什么,我都无法让它在无头中加载。

我已遵循 StackOverflow 帖子中的建议,例如Is there a version of Selenium WebDriver that is not detectorable? window我还查看了和对象的所有属性window.navigator,并修复了无头和非无头之间的所有差异,但不知何故仍然检测到无头。此时我非常好奇 Cloudflare 如何能够找出其中的差异。谢谢你的时间!

我尝试过的事情列表:

  • 用户代理
  • 替换cdc_为 chromedriver 中的另一个字符串
  • options.add_experimental_option("excludeSwitches", ["enable-automation"])
  • options.add_experimental_option('useAutomationExtension', False)
  • options.add_argument('--disable-blink-features=AutomationControlled')(这是让网站以非无头方式加载所必需的)
  • navigator.webdriver = undefined
  • 设置navigator.pluginsnavigator.languages、 和navigator.mimeTypes
  • window.ScreenY, window.screenTop, window.outerWidth,设置window.outerHeight为非零
  • 设置window.chromewindow.navigator.chrome
  • 将图像的宽度和高度设置为非零
  • 设置WebGL参数
  • 使固定Modernizr

重复实验

为了让网站在正常(非无头)Selenium 中加载,您必须点击_blank另一个网站的链接(以便目标网站在另一个选项卡中打开)。要复制该实验,首先创建一个包含内容的 html 文件<a href="https://poocoin.app" target="_blank">link</a>,然后在以下代码中粘贴该 html 文件的路径。

下面的版本(非无头)运行良好并加载网站,但如果您设置 …

python selenium bots webdriver selenium-webdriver

35
推荐指数
1
解决办法
6万
查看次数

WebDriver executeAsyncScript vs executeScript

executeAsyncScript和executeScript有什么区别?我如何使用window.onload等事件?我试过这样的事

((JavascriptExecutor) driver).executeAsyncScript("window.onload = function() {alert('Hello')}"); 
Run Code Online (Sandbox Code Playgroud)

但当然它没有用......所以如果有人知道它是如何工作的,请写一个例子

javascript testing selenium qa webdriver

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