应该很简单,我正在尝试使用Protractor点击一个图像链接。
<a href="//safeweb.norton.com
/a>我知道我走了很长的路。
var nortonlink = element(by.css('[href="//safeweb.norton.com/"]'));
nortonlink.click();
expect(browser.getCurrentUrl()).toEqual('https://safeweb.norton.com/');我的expect一直说它仍然在当前页面上,所以没有操作点击。
发布于 2016-08-05 00:23:46
您可能需要等待,直到到达目标页面。在量角器4中添加了相关的urlIs Expected Condition:
var nortonlink = $('[href*=safeweb]'); // NOTE: also simplified the selector
nortonlink.click();
var EC = protractor.ExpectedConditions;
browser.wait(EC.urlIs("https://safeweb.norton.com/"), 5000);我不确定您是否需要这里的尾部斜杠-尝试使用和不使用。
发布于 2016-08-05 00:25:00
使用protractor.ExpectedConditions检查链接是否可点击。然后点击它。
var EC = protractor.ExpectedConditions;
var nortonlink = element(by.css('[href="//safeweb.norton.com/"]'));
nortonlink.click().then(function(){
//wait until page completely loaded
browser.wait(function () {
return browser.getCurrentUrl().then(function (url) {
if(url==!"old url"){
return true;
} });
}, 8000, 'URL has not changed');
expect(browser.getCurrentUrl()).toEqual('https://safeweb.norton.com/');
});https://stackoverflow.com/questions/38772612
复制相似问题