最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to change URL in protractor - Stack Overflow

programmeradmin1浏览0评论

I'm wondering how do you change the current URL upon pressing some button or link.

browser.waitForAngular();
expect(browser.driver.getCurrentUrl()).to.eventually.match(/document/).and.notify(callback);

I know this code will get the url and match it with document, I would like to set the URL upon a click.

e.g. I'm on Facebook and I want to go to profile, I click Profile button but want to update the URL by parsing a string value to it rather than a class/function

As I have a piece of code that doesn't have any classes to point to, the only thing I have is a href which contains the path location to the page.

I'm wondering how do you change the current URL upon pressing some button or link.

browser.waitForAngular();
expect(browser.driver.getCurrentUrl()).to.eventually.match(/document/).and.notify(callback);

I know this code will get the url and match it with document, I would like to set the URL upon a click.

e.g. I'm on Facebook and I want to go to profile, I click Profile button but want to update the URL by parsing a string value to it rather than a class/function

As I have a piece of code that doesn't have any classes to point to, the only thing I have is a href which contains the path location to the page.

Share Improve this question edited Apr 28, 2015 at 20:19 alecxe 475k127 gold badges1.1k silver badges1.2k bronze badges asked Apr 28, 2015 at 18:04 PauliePaulie 7,0354 gold badges21 silver badges36 bronze badges 1
  • Are you looking for something like browser.get() or browser.driver.get()?angular.github.io/protractor/#/… – Aaron Commented Apr 28, 2015 at 18:26
Add a ment  | 

1 Answer 1

Reset to default 3

Why don't actually let the browser navigate to the new URL on click, get it via browser.getCurrentUrl(), modify it and navigate to the modified URL, e.g.

button.click();

browser.getCurrentUrl().then(function (url) {
    browser.get(url + "?a=b");
});
发布评论

评论列表(0)

  1. 暂无评论