【发布时间】:2019-10-09 19:39:00
【问题描述】:
当我尝试在 Firefox 中运行 Protractor e2e 测试时,它会启动浏览器,但我的测试脚本没有被执行。
我使用的是 windows Server 2012 R2 机器,firefox 版本 46.0.1 和 Selenium 2.53.0。
它给了我以下错误:
Using FirefoxDriver directly...
[launcher] Running 1 instances of WebDriver
code\ui\dgui\node_modules\protractor\node_modules\selenium-webdriver\http\util.js:89
Error('Timed out waiting for the WebDriver server at ' + url));
^
Error: Timed out waiting for the WebDriver server at http://127.0.0.1:58798/hub
我尝试独立运行 Selenium
code\ui\dgui\node_modules\protractor\selenium>java -jar selenium-server-standalone-2.53.0.jar
09:37:21.214 INFO - Launching a standalone Selenium Server
09:37:21.285 INFO - Java: Oracle Corporation 25.91-b14
09:37:21.285 INFO - OS: Windows Server 2012 R2 6.3 amd64
09:37:21.293 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b
09:37:21.332 INFO - Driver class not found: com.opera.core.systems.OperaDriver
09:37:21.332 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
09:37:21.336 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN8
09:37:21.336 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
09:37:21.336 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
09:37:21.434 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
09:37:21.434 INFO - Selenium Server is up and running
我正在使用npm run e2e 命令来执行我的测试
我的配置文件:
exports.config = {
allScriptsTimeout: 30000,
suites: {
test Suit: 'e2e/TestSuites/Tests/*.js',
},
multiCapabilities: [
// We will want to eventually include the following options to split out tests to multiple instances
{'browserName': 'firefox'}
],
// only for firefox and chrome - IE will require using a selenium server
directConnect : true,
// make sure that the baseURL reflects the configuration of the web server
baseUrl: 'http://10.26.5.13:8000/',
framework: 'jasmine2',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
},
onPrepare: function() {
var jasmineReporters = require('jasmine-reporters');
browser.driver.manage().window().maximize();
return browser.getProcessedConfig().then(function(config) {
var browserName = config.capabilities.browserName;
var junitReporter = new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'tests/test-results',
// this will produce distinct xml files for each capability
filePrefix: browserName + '-xmloutput',
modifySuiteName: function(generatedSuiteName, suite) {
// this will produce distinct suite names for each capability,
// e.g. 'firefox.login tests' and 'chrome.login tests'
return browserName + '.' + generatedSuiteName;
}
});
jasmine.getEnv().addReporter(junitReporter);
});
},
resultJsonOutputFile: 'tests/test-results/output.json'
};
【问题讨论】:
-
是因为 selenium 独立运行 127.0.0.1:4444/wd/hub 并且量角器正在 127.0.0.1:58798/hub 搜索 WebDriver 服务器
-
如果是这样,我如何在 Protractor 中更新 WebDriver 服务器位置
-
我的配置文件:multiCapabilities: [ {'browserName': 'firefox'}, // {'browserName': 'chrome'} ], directConnect : true,
-
如果您使用的是
directConnect,则根本不应该访问 selenium 服务器。你确定你的配置被正确提取了吗?你能编辑你的问题并包括你的整个配置文件和你用来启动量角器的命令吗? -
@NickTomlin 包含了我的配置文件。
标签: protractor