我在 Protractor 中做了一些测试,遇到了一个小问题:
我做了一个注册新用户的测试,当我完成注册后,url 将是这样的:
#/user/592/profile
所以,我的问题是,我怎样才能设法让新用户的 ID 在我的测试中得到一个 true?像这样:
expect(browser.getCurrentUrl()).toEqual(browser.baseUrl+#/user/ID_OF_NEW_USER/profile);
我该怎么做?如果可能的话当然可以。
最佳答案
以下代码适用于用户 ID 中的任意数字。
browser.getCurrentUrl().then(function(url){
var user_id=url.split("user/")[1].replace("/profile","");
//it will return exactly user_id value
expect(browser.getCurrentUrl())
.toEqual(browser.baseUrl+"#/user/"+user_id+"/profile");
});
关于angularjs - Protractor :如何在注册新用户后期望浏览器 url 等于具有 id 的 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38965497/