Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current URL of browser

In Selenium Nodejs, How can I get the current url of the page I'm testing (the moment my test script is running assume that the page initially has been redirected)

like image 214
Keo Strife Avatar asked Apr 16 '14 20:04

Keo Strife


People also ask

How do I get the HTML URL?

The current URL can be obtained by using the 'URL' property of the Document object which contains information about the current URL. The 'URL' property returns a string with the full location of the current page, along with containing the string having the HTTP protocol such as ( http://).

How can we get URL of the current page in JavaScript?

The window.location.href property returns the URL of the current page.

How do I get the current URL in Python?

You can get the current url by doing path_info = request. META. get('PATH_INFO') http_host = request.


1 Answers

driver.get("http://www.google.com")
    .then(function() {
        return driver.getCurrentUrl();
    })
    .then(function(currentUrl) {
        // work with the current url of browser
    });
like image 66
shawnzhu Avatar answered Oct 16 '22 20:10

shawnzhu