解决方案转载自:
使用appium wd.close()时遇见报错:
Method is not implemented ..
在使用webdriver操作时,点击主窗口的链接,会弹出子窗口。此时就会有两个窗口,如主窗口为mainWindow,子窗口为detailWindow。
1、使用detailWindow = mainWindow.switchTo().window(detailWindowHandle); 切换并定位到子窗口中。
2、然后关闭子窗口,调用detailWindow.quit(),
3、mainWindow.switchTo().window(mainWindowHandle); 切换回到父窗口
4、mainWindow.quit();关闭父窗口
程序执行到第四步时,出错了,提示类似“no a session ……”错误信息,
查了一下网上的webdreiver 的 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 ,此方法是关闭当前窗口,或最后打开的窗口。
部分代码如下:
1. webDriver.Close() - Close the browser window that the driver has focus of //关闭当前焦点所在的窗口
2. webDriver.Quit() - Calls dispose //调用dispose方法
3. webDriver.Dispose() Closes all browser windows and safely ends the session 关闭所有窗口,并且安全关闭session
大功造成,特此记录一下。