.debug() 建議編輯
此命令會暫停測試執行,並為使用者提供 REPL 介面,他們可以在其中輸入
任何可用的 Nightwatch 命令或斷言,它們將在正在執行的瀏覽器中執行
即時執行。
這可以用來偵錯為什麼某個命令未如預期運作,或是某個斷言
失敗,方法是以不同的方式嘗試命令和斷言 (嘗試使用不同的斷言
定位器,直到找到正確的一個),或者只是玩一下可用的 Nightwatch 命令
和斷言。
用法
範例
// async function is required while using the debug
// command to get the correct result as output.
this.demoTest = async function (browser) {
browser.debug();
// with no auto-complete
browser.debug({preview: false});
// with a timeout of 6000 ms (time for which the interface
// would wait for a result).
browser.debug({timeout: 6000})
};
參數
名稱 | 類型 | 描述 |
---|---|---|
config 可選 |
物件 | REPL 介面的配置選項。 |
callback 可選 |
函式 | 可選的回呼函式,在命令完成時呼叫。 |