.getCurrentUrl() 建議編輯
擷取目前頁面的 URL。
用法
.getCurrentUrl([callback])
範例
describe('Navigation commands demo', function() {
test('demoTest', function(browser) {
// navigate to new url:
browser.navigateTo('https://nightwatch.dev.org.tw');
// Retrieve to url with callback:
browser.getCurrentUrl(function(result) {
console.log(result.value);
});
});
test('demoTestAsync', async function(browser) {
const currentUrl = await browser.navigateTo('https://nightwatch.dev.org.tw').getCurrentUrl();
console.log('currentUrl:', currentUrl); // will print 'https://nightwatch.dev.org.tw'
});
});
參數
名稱 | 類型 | 描述 |
---|---|---|
callback 選用 |
函式 |