angularjs – 无法使量角器等待现有元素可点击(condition.elemen
发布时间:2020-12-17 17:08:53 所属栏目:安全 来源:网络整理
导读:我们有一个Angular 1.5应用程序,它有一个登录屏幕,在应用程序代码和我们的测试中没有任何改变.我们使用量角器(与grunt-protractor等…) 版本: "dependencies": { "async": "^0.9.0","chalk": "^1.1.1","fs-extra": "^0.24.0","grunt": "~0.4.5","grunt-cont
我们有一个Angular 1.5应用程序,它有一个登录屏幕,在应用程序代码和我们的测试中没有任何改变.我们使用量角器(与grunt-protractor等…)
版本: "dependencies": { "async": "^0.9.0","chalk": "^1.1.1","fs-extra": "^0.24.0","grunt": "~0.4.5","grunt-contrib-jshint": "^0.10.0","grunt-protractor-runner": "^4.0.0","grunt-protractor-webdriver": "^0.2.5","jshint-stylish": "^1.0.0","load-grunt-tasks": "~3.1.0","lodash": "^2.4.1","log4js": "^0.6.21","protractor": "^4.0.11","selenium-webdriver": "^3.0.1" } 我们所有的测试都采用以下格式: >登录应用程序并睡觉 describe('login',function () { browser.get('/'); components.login.loginDefault(); console.log('done login'); browser.driver.manage().window().maximize(); // just in case the driver wont reach the '.add-new-type' button browser.sleep(1000); }); describe('post login',function () { it('just a test for after user loged in',function (done) { console.log('post login'); const ec = protractor.ExpectedConditions; const getStarted = element(by.css('.add-new-type')); // just a button appears on the next page console.log('getStarted ' + JSON.stringify(getStarted)); browser.wait(ec.elementToBeClickable(getStarted),5000); console.log('post wait'); browser.sleep(5000).then(done); })}); 我们没有更改依赖项版本或在我们的环境中没有任何内容,突然没有任何工作,测试只通过登录阶段然后失败,因为没有找到元素(我猜)并且卡住直到jasmine抛出超时异常 Session created: count=1,browserName=chrome,chromeOptions={args=[--no-sandbox,--test-type=browser,--disable-extensions],prefs={download={default_directory=./e2e/tmp,prompt_for_download=false}}} node path changed done login Started post login F 登录后测试只是一个例子,我们尝试了其他方法让驱动程序等待“ExpectedConditions”. element(by.css('.add-new-type')).getText() 行为是一样的 – 没有/没有回应 请问有什么帮助! 解决方法
你有没有尝试过等待元素和网址?
'use strict'; var WaitUtils = function () { this.waitElement = function (element,timeout) { timeout = timeout || browser.params.time.long; var expected = protractor.ExpectedConditions; return browser.wait(expected.visibilityOf(element),timeout,"Element not found"); }; this.waitUrl = function (url,timeout) { timeout = timeout || browser.params.time.long; var expected = protractor.ExpectedConditions; return browser.wait(expected.urlContains(url),"URL has not contains "+url); }; }; module.exports = WaitUtils; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |