Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
詹金斯&x2B;WebDriver&x2B;量角器:由以下原因引起:org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话_Selenium_Jenkins_Selenium Webdriver_Protractor - Fatal编程技术网

詹金斯&x2B;WebDriver&x2B;量角器:由以下原因引起:org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话

詹金斯&x2B;WebDriver&x2B;量角器:由以下原因引起:org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话,selenium,jenkins,selenium-webdriver,protractor,Selenium,Jenkins,Selenium Webdriver,Protractor,我想让詹金斯做量角器测试。 我知道我需要在没有浏览器的情况下运行量角器。如何设置它 我需要安装哪些npm软件包? 我的实际包是(在package.json中): } 在我的本地机器中,一切都很好,因为我看到chrome窗口打开,我看到测试正在进行 但当我尝试在Jenkins上运行它时,我得到了以下信息: 原因:org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。 构建信息:版

我想让詹金斯做量角器测试。 我知道我需要在没有浏览器的情况下运行量角器。如何设置它

我需要安装哪些npm软件包? 我的实际包是(在package.json中):

}

在我的本地机器中,一切都很好,因为我看到chrome窗口打开,我看到测试正在进行

但当我尝试在Jenkins上运行它时,我得到了以下信息:

原因:org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。
构建信息:版本:'2.45.0',版本:'5017cb8',时间:'2015-02-26 23:59:50',ip:'127.0.1.1',os.name:'Linux',os.arch:'amd64',os.version:'3.13.0-24-generic',java.version:'1.8.0_25' 驱动程序信息:Driver.version:ChromeDriver 位于org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593) 位于org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240) 位于org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:126) 位于org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:139) 位于org.openqa.selenium.chrome.ChromeDriver(ChromeDriver.java:171) 位于org.openqa.selenium.chrome.ChromeDriver(ChromeDriver.java:139) ... 14更多
原因:org.openqa.selenium.WebDriverException:等待驱动程序服务器启动时超时。
构建信息:版本:'2.45.0',版本:'5017cb8',时间:'2015-02-26 23:59:50',ip:'127.0.1.1',os.name:'Linux',os.arch:'amd64',os.version:'3.13.0-24-generic',java.version:'1.8.0_25' 驱动程序信息:Driver.version:ChromeDriver 位于org.openqa.selenium.remote.service.DriverService.start(DriverService.java:171) 位于org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62) 位于org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:572) ... 19更多
原因:org.openqa.selenium.net.UrlChecker$TimeoutException:等待[在20001毫秒后可用]超时 位于org.openqa.selenium.net.UrlChecker.waitUntilavable(UrlChecker.java:104) 位于org.openqa.selenium.remote.service.DriverService.start(DriverService.java:168) …还有21个

My progrator.conf.js:

exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',

// Capabilities to be passed to the webdriver instance.
capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
        'args': ['incognito', 'disable-extensions', 'start-maximized', 'enable-crash-reporter-for-testing', '--test-type']
    },
    'loggingPrefs': {
        'browser': 'ALL'
    }
},

getPageTimeout: 20000,

    framework: 'jasmine2',

// Spec patterns are relative to the current working directly when
// protractor is called.

specs: ['global_setup.js', 'scenarios.js', 'campaign-grid-scenarios.js', 'create-campaign-scenarios.js'],
baseUrl: 'http://localhost:18090',

// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000
}
})

是什么导致了超时?是因为webdriver是chrome,但chrome无法在我的jenkins设置中打开吗? 我一直在寻找类似的问题,但没有发现任何相关的问题


谢谢。

这是因为您的Jenkins安装程序中没有安装chrome。根据您的情况,您可以选择几个选项

  • 如果您有一个独立的Jenkins实例,并且您知道不会有任何随机选择的节点,那么您可以使用无头浏览器实现,如。您需要确保
    phantomjs
    安装在您的Jenkins上,并告诉您的测试在
    phantomjs
    上运行,而不是
    chrome
    browserName:'phantomjs'
    。您不需要在package.json中包含phantomjs。只需确保安装了phantomjs,并且其可执行文件位于路径中的某个位置即可

  • 其次,您可以设置一个Selenium网格,并使用您想要测试的不同浏览器设置节点。从Jenkins开始,您可以在您选择的浏览器上对远程Selenium网格运行测试。如果您希望这样做,可以使用付费的第三方选项,如sauce labs或浏览器堆栈


  • 我想在一个独立的Jenkins实例上运行它,我知道像phantomjs这样的无头浏览器是我要寻找的。你能更明确地说明我要做什么配置才能让这个场景工作吗?正如你所说的,我应该告诉我的测试在phantomjs上运行。这意味着功能。browserName:“phantomjs”?但在此之前我需要将“phantomjs”添加到我的“package.json”中,对吗?还有什么?谢谢您的时间@nilesh.right,只需告诉browserName:“phantomjs”,并确保phantomjs已安装并在Jenkins服务器上的路径中。无需向package.json添加任何内容。我更新了应答器官方文档建议不要使用phantomjs[请参阅] ().你在@nilesh的经历是什么?我应该担心吗?我使用PhantomJS进行冒烟测试和快速响应,因为它比普通浏览器更快,因为它是无头的。效果很好。如果冒烟测试通过,我会在远程selenium网格上运行完整的功能测试套件。因为PhantomJS不是真正的浏览器,只是simula注意,我同意量角器的观点,你不应该在最后阶段使用PhantomJS来验证你的构建。我建议在测试的一小部分中使用PhantomJS,并为完整的功能套件设置一个网格来最终验证构建。感谢你花时间@nilesh。明天我将尝试设置PhantomJS。今年晚些时候我将尝试了解如何使用selenium网格运行我的测试。您是否推荐任何可以解释如何设置selenium网格的链接/博客/书籍(使用jenkins..=)?
    exports.config = {
    // The address of a running selenium server.
    seleniumAddress: 'http://localhost:4444/wd/hub',
    
    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {
            'args': ['incognito', 'disable-extensions', 'start-maximized', 'enable-crash-reporter-for-testing', '--test-type']
        },
        'loggingPrefs': {
            'browser': 'ALL'
        }
    },
    
    getPageTimeout: 20000,
    
        framework: 'jasmine2',
    
    // Spec patterns are relative to the current working directly when
    // protractor is called.
    
    specs: ['global_setup.js', 'scenarios.js', 'campaign-grid-scenarios.js', 'create-campaign-scenarios.js'],
    baseUrl: 'http://localhost:18090',
    
    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    }