【问题标题】:how to set $interval instead of timeout in Protractor Tests如何在量角器测试中设置 $interval 而不是超时
【发布时间】:2015-05-18 12:10:59
【问题描述】:

我正在使用 appiumProtractor 进行 iOS 混合应用自动化。我在我的 config.js 文件中使用超时但收到错误:下面是我的 config.jsspec.js 文件。

请告知如何使用 $interval 而不是 timeout。

Config.js:

exports.config = { allScriptsTimeout: 30000 , getPageTimeout: 30000 , 忽略同步:真, seleniumAddress: 'http://localhost:4723/wd/hub',

 specs: ['PageObjectSpec.js'],

 capabilities: {
     browserName: 'iOS' ,
    'appium-version':'1.3.4',
     platformName:'iOS'   ,
     platformVersion: 7.1 ,
     deviceName:'iPhone' ,
     autoWebview:true , 
    },
  baseUrl: 'http://localhost:8000',   
 jasmineNodeOpts: {showColors: true, defaultTimeoutInterval:60000} ,
 onPrepare: function() {
 browser.manage().timeouts().setScriptTimeout(60000);
  }, 
};

Spec.js 文件::

'use strict';
describe('Abbvie app test', function() 

{
 var userName = browser.element(by.model('credentials.username'));  
 var passwd = browser.element(by.model('credentials.password'));
 var signin = browser.element(by.buttonText('Sign In'));
it('Login Page test', function()
 {
 userName.click();
 //userName.sendKeys(name)

 passwd.click();
 //passwd.sendKeys(pass)
signin.click();

}, 60000);
});

**量角器日志:**使用 selenium 服务器在

http://localhost:4723/wd/hub
[launcher] Running 1 instances of WebDriver
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
The last active task was: 
Protractor.waitForAngular()
    at [object Object].webdriver.WebDriver.schedule (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:345:15)
    at [object Object].Protractor.executeAsyncScript_ (/usr/local/lib/node_modules/protractor/lib/protractor.js:251:26)
    at [object Object].Protractor.waitForAngular (/usr/local/lib/node_modules/protractor/lib/protractor.js:274:15)
    at [object Object].getWebElements (/usr/local/lib/node_modules/protractor/lib/element.js:136:19)
    at [object Object].getWebElements (/usr/local/lib/node_modules/protractor/lib/element.js:669:31)
    at [object Object].ElementArrayFinder.applyAction_ (/usr/local/lib/node_modules/protractor/lib/element.js:391:28)
    at [object Object].self.(anonymous function) [as click] (/usr/local/lib/node_modules/protractor/lib/element.js:77:19)
    at [object Object].self.(anonymous function) [as click] (/usr/local/lib/node_modules/protractor/lib/element.js:698:11)
    at [object Object].<anonymous> (/Users/qualcomm/Desktop/ProtractorTest/PageObjectSpec.js:13:11)
F

Failures:

  1) Abbvie app test Login Page test
   Message:
     timeout: timed out after 60000 msec waiting for spec to complete
   Stacktrace:
     undefined

Finished in 65.404 seconds
1 test, 1 assertion, 1 failure

[launcher] 0 instance(s) of WebDriver still running
[launcher] iOS #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1

请提出您的建议。 谢谢,

【问题讨论】:

  • 您的应用中使用了什么角度版本? $interval 在旧版本中不可用。 waitForAngular 被阻塞,直到不再有 $http 和 $timeout 运行。我看到你在exports.config 中使用了ignoreSynchronization=true;但是如果 60+sec 后出现 waitForAngular 超时,则显然没有设置为 true。我使用ignoreSynchronization=true;在之前的块中并进行手动同步,因为我很遗憾需要在 1.07 版中使用 angualar

标签: javascript ios protractor appium


【解决方案1】:

实际上不可能使用$interval 来代替config.js 文件中的默认timeout 参数。

我猜您问的原因是如果您遇到超时问题,Protractor 文档建议在您的 Angular 应用程序中使用 $interval 而不是 $timeout。这不是你的量角器测试中需要改变的东西;这是需要在应用本身中改变的东西。

您自己的文件看起来不错。

你的错误有点奇怪。与应用程序开发人员交谈,看看他们是否能找到不会回来的 $http$timeout。还要确保页面按预期加载;检查您的开发者控制台是否有错误,检查您的网络选项卡是否有待处理的请求,并确保一切就绪。

【讨论】:

  • 非常感谢!!艾萨克莱曼的精彩解释!!,是的,你是对的,我问是因为量角器文档建议使用 $interval 而不是超时。
猜你喜欢
  • 2015-10-04
  • 1970-01-01
  • 2017-10-03
  • 1970-01-01
  • 2017-12-03
  • 2016-08-30
  • 1970-01-01
  • 2015-02-01
  • 1970-01-01
相关资源
最近更新 更多