我在执行它们时遇到了一个问题。我正在测试一个写在aurelia上的非角度网站。我已经设置了一些关于超时的配置并忽略了同步。我仍然面临着超时问题 - 在帖子的末尾添加了堆栈跟踪。这是我的设置:
量角器:4.0.9
protractor.conf.js:
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
//seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['test/e2e/dist/**/*.js'],
plugins: [{
package: 'aurelia-tools/plugins/protractor'
}],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
},
framework: "jasmine2",
onPrepare: function(){ //configure junit xml report
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
filePrefix: 'e2e-results',
savePath: 'test/reports'
}));
}
};
以下是我的特定测试的conf.js:
exports.config = {
directConnect: true,
capabilities: {
'browserName': 'chrome'
},
restartBrowserBetweenTests: true,
//The address of a running selenium server.
framework: 'jasmine2',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 180000
},
//Here we specify the name of the specs files.
specs: ['test/e2e/dist/**/*.js'],
getPageTimeout: 120000,
allScriptsTimeout: 120000,
onPrepare: function() {
browser.ignoreSynchronization = true;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 180000;
by.addLocator('valueBind', function (bindingModel, opt_parentElement) {
var using = opt_parentElement || document;
var matches = using.querySelectorAll('*[value\\.bind="' + bindingModel +'"]');
var result = undefined;
if (matches.length === 0) {
result = null;
} else if (matches.length === 1) {
result = matches[0];
} else {
result = matches;
}
return result;
});
}
}
以下是我的测试规范的beforeEach部分:
beforeEach(function(){
browser.driver.get(URL);
browser.driver.manage().window().maximize();
browser.ignoreSynchronization = true;
browser.driver.executeAsyncScript(
'var cb = arguments[arguments.length - 1];' +
'document.addEventListener("aurelia-composed", function (e) {' +
' cb("Aurelia App composed")' +
'}, false);'
).then(function(result){
console.log(result);
});
});
堆栈跟踪
<![CDATA[ScriptTimeoutError: asynchronous script timeout: result was not received in 11 seconds
(Session info: chrome=53.0.2785.143)
(Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.3.9600 x86_64)
at WebDriverError (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:26:26)
at ScriptTimeoutError (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:291:26)
at Object.checkLegacyResponse (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:639:15)
at parseHttpResponse (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:538:13)
at C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:472:11
at ManagedPromise.invokeCallback_ (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14)
at TaskQueue.execute_ (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14)
at TaskQueue.executeNext_ (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21)
at C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2820:25
at C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7
From: Task: WebDriver.executeScript()
at Driver.schedule (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:377:17)
at Driver.executeAsyncScript (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:614:17)
at Object.<anonymous> (C:\Users\USER\Documents\Git\src\Project\test\e2e\dist\testspec.js:33:18)
at C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:94:23
at new ManagedPromise (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1082:7)
at controlFlowExecute (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:80:18)
at TaskQueue.execute_ (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14)
at TaskQueue.executeNext_ (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21)
at C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2820:25
at C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7
From: Task: Run beforeEach in control flow
at Object.<anonymous> (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:79:14)
at attemptAsync (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1980:24)
at QueueRunner.run (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1935:9)
at QueueRunner.execute (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1923:10)
at Spec.Env.queueRunnerFactory (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:714:35)
at Spec.execute (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:371:10)
at Object.fn (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:2579:37)
at attemptAsync (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1980:24)
at QueueRunner.run (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1935:9)
at QueueRunner.execute (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1923:10)
From asynchronous test:
Error
at Suite.<anonymous> (C:\Users\USER\Documents\Git\src\Project\test\e2e\dist\testspec.js:22:2)
at addSpecsToSuite (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:867:25)
at Env.describe (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:836:7)
at jasmineInterface.describe (C:\Users\USER\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3576:18)
at Object.<anonymous> (C:\Users\USER\Documents\Git\src\Project\test\e2e\dist\testspec.js:15:1)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)]]>
任何帮助将不胜感激,谢谢。
答案 0 :(得分:0)
我刚才找到了灵魂,但我忘记发布答案了。所以就是这样。
Aurelia制作了一个Protractor插件。正如我在我的问题中提到的,我自动化的应用程序是通过Aurelia框架编写的。因此,当我盯着使用此插件,特别是loadAndWaitForAureliaPage方法来加载页面时,一切都开始正常工作。