我的当前场景是:用户键入用户名、密码,然后单击登录按钮。然后,下一个屏幕显示一个列表框,其中包含要登录的Stores。量角器加载此列表框,但未在其上找到任何元素。有时,当我单击这个列表中的任何元素时,我会收到一个错误:
堆栈: ScriptTimeoutError:脚本超时(会话信息: chrome=84.0.4147.89) (驱动程序信息: chromedriver=84.0.4147.30 platform=Windows NT 10.0.18362 x86_64)
这是我的规范文件
describe('Stock Take Review', function () {
it('should do user login', function () {
browser.get('myurl');
browser.driver.manage().window().maximize();
browser.sleep(1000);
element(by.id("mat-input-0")).sendKeys('user');
element(by.id('mat-input-1')).sendKeys('Pwd');
element(by.css('.full-width')).click();///////click on login
browser.sleep(1000); );/这里,列表框列出了用户应该选择的所有存储区。
it('should select a shop', async function () {
let EC = browser.ExpectedConditions;
let elm = element(by.css('.mat-list-item:nth-child(1) .center'));
browser.wait(EC.elementToBeClickable(element(elm)), 150000);
await elm.click(); // select Koge store
browser.sleep(2000);
await element(by.css('.mat-fab > .mat-button-wrapper')).click(); // click on the play button
browser.sleep(2000);
});下面是配置文件
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
"browserName": 'chrome',
chromeOptions: {
args: ['incognito'],
mobileEmulation: {
"device": 'Zebra TC20',
"deviceMetrics": {
"width": 340,
"height": 440,
"pixelRatio": 3.0
}
}
}
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
specs: ['../tests/StockTake_Review.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 120000
},任何帮助都是非常感谢的!
发布于 2020-07-22 15:14:12
在您的配置文件中有defaultTimeoutInterval: 120000 ,
你在等待150000秒的时间
我认为,元素没有被定位,系统试图在150000毫厘内找到它,但是在120000抛出超时错误之后。
缩短显式等待时间
browser.wait(EC.elementToBeClickable(element(elm)), 10000);阅读修复程序后进行更新:
https://www.protractortest.org/#/timeouts
browser.waitForAngularEnabled(false);不要使用忽略同步发布于 2020-07-23 07:13:13
我找到了一个解决办法:在我添加的配置文件上: allScriptsTimeout: 1100000,getPageTimeout: 600000,
在spec文件上,对于失败的函数,我添加了: browser.ignoreSynchronization = true;
https://sqa.stackexchange.com/questions/45312
复制相似问题