('webdriver'),然后使用try-catch语句捕获NoSuchWindowError异常,然后在catch语句中重新启动WebDriver实例。以下是示例代码:

const webdriver = require('webdriver');

let driver = new webdriver.Builder().forBrowser('chrome').build();

try {
  // do something with driver
} catch (err) {
  if (err.name === 'NoSuchWindowError') {
    driver.quit();
    driver = new webdriver.Builder().forBrowser('chrome').build();
    // retry the failed code with the new driver instance
  }
}

原文地址: http://www.cveoy.top/t/topic/gELW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录