您的位置:首页 > 产品设计 > UI/UE

WebDriver中close()与quit()的不同

2013-08-05 17:05 281 查看
测试技术交流群:161204772

悦分享测试联盟:136924235

悦分享主页:http://www.bjhxcc.com/special/2013/0822/yfx.htm
今天在使用webdriver操作两个窗口时,其中父窗口为parent,子窗口为sub

1、使用driver.switchTo().window(sub);

2、然后关闭子窗口,调用driver.quit(),

3、driver.switchTo().window(parent);切换回到父窗口

4、driver.quit();关闭父窗口

程序执行到第四步时,出错了,提示类似“no a session ……”错误信息,查了一下api,才发现,quit()详细信息“Quits this driver, closing every associated window”,执行这个方法后,driver会关闭所有关联窗口

close()详细信息:Close the current window, quitting the browser if it's the last window currently open ,此方法是关闭当前窗口,或最后打开的窗口

弄明白了,这两个方法的不同,以上错误信息就能迎刃而解了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: