admin管理员组

文章数量:1421557

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");
});

本文标签: javascriptHow to change URL in protractorStack Overflow