監聽 console 事件 (例如 console.log 事件) 並註冊回呼函式來處理它。

用法

                    .captureBrowserConsoleLogs(onEventCallback)
                

範例

 describe('capture console events', function() {
   it('captures and logs console.log event', function() {
     browser
       .captureBrowserConsoleLogs((event) => {
         console.log(event.type, event.timestamp, event.args[0].value);
       })
       .navigateTo('https://www.google.com')
       .executeScript(function() {
         console.log('here');
       }, []);
   });
 });

參數

名稱 類型 描述
onEventCallback 函式

每當捕獲到新的控制台事件時,就會呼叫的回呼函式。