1

I've been trying to get the current URL and am wanting to cut out parts of the URL to use in another method. I've tried many ways, and one solution I saw online suggested using the beforeEach() method. I've been trying this and no matter what, this.urlString always returns undefined.

Heres what i current have. I must be missing something as to why this is returning undefined however I can't figure it out.

this.urlString;

beforeEach(function () {
  mainPO.navigateHome();
  mainPO.clickCurrent();

  browser.getCurrentUrl().then(function (url) {
    return this.urlString = url;
  });
});

console.log(this.urlString)

What I want to do is store the URL in a string, then parse the string to cut out everything before the ".com" of the URL so i can take the string and plug it into another URL for crawling to another link.

4

1 に答える 1