.navigateTo() 建議編輯
自:2.0.0導覽至新的 URL。這個方法也會在頁面載入後立即呼叫 onBrowserNavigate()
測試全域變數。
用法
.navigateTo(url, [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'
});
});
參數
名稱 | 類型 | 描述 |
---|---|---|
url |
字串 | 要導覽至的網址 |
callback 選填 |
函數 |