Selenium Webdriver sessionId 或检查所有浏览器窗口是否已关闭 [英] Selenium Webdriver sessionId or check if all browser windows are closed

查看:39
本文介绍了Selenium Webdriver sessionId 或检查所有浏览器窗口是否已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法查看所有浏览器窗口是否关闭?我看到,如果您在 WebDriver 上调用 driver.quit() 或 driver.close(),则 sessionId 将变为 null.有没有办法检查?

Is there a way to see if all the browser windows are closed? I see that if you call driver.quit() or driver.close() on the WebDriver, the sessionId becomes null. Is there a way to check that?

我不想调用已关闭或退出的驱动程序,因为它会引发 WebDriverException.所以我想在继续之前检查浏览器的状态.

I don't want to make a call to a closed or quit driver as it throws a WebDriverException. So I want to check to see the state of the browser before continuing on.

推荐答案

只需设置

driver=null; 

每次你退出浏览器然后检查

everytime you quit the browser and than check

if (browser!=null){
  //Attention: this comand is not supported
  //as far as i know ;)
  driver.doSomething();
}

try{


}catch (NullPointerException e)

    e.printStackTrace();
    System.err.print"DAMN";
}

或收到 NullPointerException ;)

or receive a NullPointerException ;)

这篇关于Selenium Webdriver sessionId 或检查所有浏览器窗口是否已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆