angularjs – isElementPresent的简单量角器测试失败,不支持定位
发布时间:2020-12-17 08:52:25 所属栏目:安全 来源:网络整理
导读:我的测试: it('should allow login',function() { browser.get('index.html'); $('#username').sendKeys('administrator'); $('#password').sendKeys('password'); $('#login').click(); var logout = $('#logout'); expect($p.isElementPresent(logout)).t
我的测试:
it('should allow login',function() { browser.get('index.html'); $('#username').sendKeys('administrator'); $('#password').sendKeys('password'); $('#login').click(); var logout = $('#logout'); expect($p.isElementPresent(logout)).to.eventually.be.true; }); 但这错误: Error: Unsupported locator strategy: click at Error (<anonymous>) at Function.webdriver.Locator.createFromObj (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/locators.js:97:9) at Function.webdriver.Locator.checkLocator (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/locators.js:111:33) at webdriver.WebDriver.findElements (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:805:31) at webdriver.WebDriver.isElementPresent (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:787:29) at Protractor.isElementPresent (/usr/local/lib/node_modules/protractor/lib/protractor.js:476:22) at /Users/pschuegr/wt/client/e2e/login_test.js:26:15 奇怪的是,它指向isElementPresent行,而不是点击的行.我对webdriver很新,所以如果我错过了一些明显的东西,请道歉.我正在使用mocha框架(这意味着量角器的金丝雀版本),fwiw. 任何想法都赞赏.
$(‘#logout’)是一个WebElement. isElementPresent采用定位器,如by.css
$('#username').sendKeys('administrator'); $('#password').sendKeys('password'); $('#login').click(); var logout = by.css('#logout'); browser.wait(function() { return $p.isElementPresent(logout); },8000); expect($p.isElementPresent(logout)).toBeTruthy(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |