2017-05-07 63 views
1

节点版本:v6.9.4量角器点击功能不起作用,它抛出超时异常错误

量角器版本:5.1.1

角版本:1.2.28

浏览器(S):Chrome:Version 58.0.3029.96 (64-bit) Chrome WebDriver:Version 2.29

操作系统和版本:MAC OS Siera 10.12.3

量角器配置文件

exports.config = { 
    directConnect: true, 
    capabilities: { 
    'browserName': 'chrome' 
    }, 
    framework: 'jasmine', 
    specs: ['./Test/LoginTest.js'], 
    allScriptsTimeout: 120000, 
    getPageTimeout: 120000, 
    jasmineNodeOpts: { 
    showColors: true, 
    defaultTimeoutInterval: 120000 
} 

一个相关的例子测试

有按钮的页面,当我尝试点击使用量角器,它将引发超时错误。无法点击该元素。硒webdriver同样的工作。

步骤来重现 步骤1:使用该URL https://www.neonmob.com/login

步骤2打开网站:Enter the user name and password mentioned below and click on Login button 用户名:sharif33332 密码:1234

步骤3:登录后导航到此URL https://www.neonmob.com/shariftestuser以导航到确切的p发生问题的年龄。

问题Now at this page unable to click on Trade Button and it throws time out exception error.

相同的元素可以使用jQuery找到。请按照上述步骤重现此问题。

用下面的代码点击这个按钮

element(by.css("span[id='trade-btn']")).click();

请让我知道,如果你不能够遵循的步骤。我相信这是在protratcor

+0

无法看到交易按钮XD - 我刚看到它 –

回答

-1

检查后一个问题,你的第二个URL(似乎没有)是一个角度页面,需要ignoreSynchronization。

尝试使用下面的代码:

describe('angularjs homepage todo list', function() { 
    it('should add a todo', function() { 
    browser.get('https://www.neonmob.com/login'); 
    element(by.id('field-username')).sendKeys('sharif33332'); 
    element(by.id('field-password')).sendKeys('1234'); 
    element(by.id('signin-btn')).click(); 
    browser.waitForAngular(); 
    browser.ignoreSynchronization=true 
    browser.executeScript('this.document.location = "https://www.neonmob.com/shariftestuser"'); 
    element(by.id('trade-btn')).click(); 
    }); 
}); 

我没有固定的格式,你可以做到这一点的。 :)

没什么特别的配置,以及,我只能用这个:

exports.config = { 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    specs: ['spec.js'], 
    jasmineNodeOpts: {defaultTimeoutInterval: 60000} 
}; 
+0

你曾经通过系统提供的信息尝试过吗?那么你会看到它不会工作,因为等待角度超时 – wswebcreation

+0

有一个问题,为什么你不登录'shariftestuser'而不是'sharif33332'? 你在这里测试一个特定的功能吗? –

+0

页面“https://www.neonmob.com/shariftestuser”是一个角度页面。只要打开你的控制台并键入'angular',你就会得到角度对象。当您通过Chrome中的devtools查看DOM时,您还可以在代码中找到Angular调试信息。 – wswebcreation

1

我发现这个问题。量角器没有问题。页面出现问题。你点击按钮时没有超时/没有找到它。你会收到一个错误,因为Angular没有发布页面,所以页面超时。仍然有公开的电话或者让Angular保持未准备好的状态。这是我

Failures: 
1) click on trade button should click on the trade button 
    Message: 
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. 
    Stack: 
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. 
     at ontimeout (timers.js:365:14) 
     at tryOnTimeout (timers.js:237:5) 
     at Timer.listOnTimeout (timers.js:207:5) 
    Message: 
    Failed: Timed out waiting for asynchronous Angular tasks to finish after 30 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular 
    While waiting for element with locator - Locator: By(css selector, #trade-btn). 
    The following tasks were pending: 
    - $timeout: function(){ownershipPromise=artPieceService.syncOwnership()} 

日志如果禁用等待角本会工作

describe('click on trade button',() => { 
    beforeEach(function() { 
     browser.get(browser.baseUrl); 
     $('#field-username').sendKeys('sharif33332'); 
     $('#field-password').sendKeys('1234'); 
     $('#signin-btn').click(); 
     browser.driver.wait(() => browser.getCurrentUrl().then((currentUrl) => currentUrl === 'https://www.neonmob.com/sharif33332')); 
     browser.get('https://www.neonmob.com/shariftestuser') 
    }); 

    it('should click on the trade button',() => { 
     // Disable wait for Angular 
     browser.ignoreSynchronization = true; 
     // Wait 2 seconds for the page to be loaded 
     browser.sleep(2000) 
     $('#trade-btn').click(); 
     // Wait to verify that the trade button has been clicked. 
     browser.sleep(5000); 
    }) 
}); 

这将确认有没有错,量角器,但你必须潜入角上本页面/请开发人员修复此问题。

+0

的代码中解决,如果它是角页面,则有一个函数在检查对象之前等待页面加载。 你也可以使用browser.sleep,但秒数是固定的。 您还可以尝试使用可充当“waitForAngular”函数的递归函数。 http://stackoverflow.com/questions/43656135/changing-protractor-default-timeout-inside-function/43679616#43679616 –

+0

也设置超时到120秒,这并没有帮助。这意味着睡眠也不会奏效。我认为页面上的时间间隔有问题,并保持打开http调用 – wswebcreation

0

@wswebcreation,你确定这不是角度页面。如果不是那么角度等待将不起作用。将需要browser.ignoreSynchronization = true。

无论如何,我会要求我们的开发人员对此进行研究并进行调试,以便从应用程序端进行修复。

无论如何目前解决方案提供上述工作正常。

非常感谢你的帮助

+0

嗨,我敢肯定。检查页面的源代码。如果你打开页面,检查你将在第567行看到的第一个引用Angular的源代码,然后在第586行加载角度文件,并在body标签中'ng-app'参考。无法给出更多证据。 您现在已经接受了错误解释的正确答案。我希望你明白他和我的回答只是一个解决方法(使用'browser.ignoreSynchronization = true'),并且会让你以正确的方式自动化页面/应用程序。 – wswebcreation