我能够运行测试代码并且能够提交表单。单击提交按钮时我需要下一页的网址。单击提交按钮时,我需要获取下一页的网址。但我得到了第一页的 currenturl 。 我的代码:
describe('Pmts app 5.0',function(){
var LoginPage = require("./LoginPO");
it('login test', function(){
LoginPage.setUserName('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="631b1a1923170610174d000c0e" rel="noreferrer noopener nofollow">[email protected]</a>');
LoginPage.setPassWord('test');
LoginPage.clickButton();
expect(browser.getCurrentUrl()).toEqual('https://localhost:1234/#/timesheet');
});
});
单击提交按钮后,浏览器立即关闭,并且不等待下一页加载。提交按钮后,它应该等到下一页加载,并且我需要下一页的 url...
最佳答案
按如下方式表述:
LoginPage.clickButton().then(function(){ expect(browser.getCurrentUrl()).toEqual('https://localhost:1234/#/timesheet');
})
或者你可以进行明确的硬性 sleep :
browser.sleep(time in ms)
或者您可以放置 browser.wait() 来等待下一页上出现的某些元素:
browser.wait(function(){
return elem.isPresent()
},time in ms).then(function(){
expect(browser.getCurrentUrl())
.toEqual('https://localhost:1234/#/timesheet');
})
关于jasmine - 如何获取Protractor中单击提交按钮的下一页的url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31718064/