2017-08-03 70 views
0

我想分配給firstPageUrl變量當前網址。請幫助我,謝謝。 Tryed使它像這樣:Nightwatch將頁面的當前網址分配給varriable

 var firstPageUrl = ""; 
    browser.url(function(result) { 
     // return the current url 
     firstPageUrl = result.value; 
     return firstPageUrl; 
    }); 
+0

您是否嘗試使用console.log(result.value)?怎麼樣console.log(firstPageUrl)?你看見什麼了? – QualiT

+0

是的,如果我在函數輸出裏面的concole.log(firstPageUrl)是當前的URL但是在外面是空的。我需要以某種方式將其分配 –

+0

您可以參考我的答案在類似的問題:https://stackoverflow.com/a/45639217/8444504 – Raymond

回答

0
var firstPageUrl = ""; 
browser.url(function(result) { 
    // return the current url 
    firstPageUrl = result.value; 
    module.exports.firstPageUrl; 
}); 

發現瞭如何解決由node.js的module.exports命令我的問題。

相關問題