Get current URL of browser
Asked Answered
B

3

8

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)

Bethanie answered 16/4, 2014 at 20:52 Comment(3)
I found this link, might be helpful: code.google.com/p/selenium/wiki/JsonWireProtocol#/session/…Bookstand
Is standard method not working here? selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/…Downwash
I'm working with nodeJSBethanie
T
20
driver.get("http://www.google.com")
    .then(function() {
        return driver.getCurrentUrl();
    })
    .then(function(currentUrl) {
        // work with the current url of browser
    });
Thallium answered 19/4, 2014 at 18:12 Comment(0)
E
0
print(api.driver.getCurrentUrl().toString())
Emancipation answered 23/3, 2023 at 17:31 Comment(0)
C
-1

To show you must to use toString:

var currentURL = driver.getCurrentUrl().toString();
console.log("***>>> getCurrentUrl: "+currentURL);
Conjoined answered 13/7, 2016 at 13:39 Comment(1)
Actually when i use your code i am getting ManagedPromise::1143 {[[PromiseStatus]]: "pending"}Exoergic

© 2022 - 2024 — McMap. All rights reserved.