joelgriffith / navalia

A bullet-proof, fast, and reliable headless browser API
https://joelgriffith.github.io/navalia/
GNU General Public License v3.0
957 stars 33 forks source link

Get current URL #61

Closed castrolol closed 6 years ago

castrolol commented 6 years ago

I have a scenario that I would like to assert the current URL, today I could not find how to do this.

Is there any way today using navalia.js to do this?

marlonpp commented 6 years ago

Hey @castrolol, see if this snippet helps you.

chrome
      .goto('http://localhost:8000')
      .then(() => chrome.click('#details'))
      .then(() => chrome.evaluate(() => window.location.href))
      .then(location =>
        expect(location).toBe('http://localhost:8000/details')
      ));
castrolol commented 6 years ago

thank you dude !

So Awesome !

joelgriffith commented 6 years ago

Thanks friends, closing this issue! Also, I believe goto returns the final URL:

chrome
      .goto('http://localhost:8000')
      .then((finalURL) => console.log(finalURL) && chrome.click('#details'))