获取浏览器的当前url

在Selenium Nodejs中,我如何获取正在testing的页面的当前url(testing脚本正在运行的那一刻,假设网页最初已被redirect)

driver.get("http://www.google.com") .then(function() { return driver.getCurrentUrl(); }) .then(function(currentUrl) { // work with the current url of browser }); 

为了显示你必须使用toString:

 var currentURL = driver.getCurrentUrl().toString(); console.log("***>>> getCurrentUrl: "+currentURL);