我正在使用Chrome和IE浏览器。我需要重新启动当前浏览器并继续执行。 当我重新启动浏览器时,关闭当前浏览器并使用给定的URL启动新浏览器,但抛出此错误:
没有这样的会话(驱动程序信息:chromedriver = 2.10.267521,platform = Windows NT 6.2 x86_64)
脚本是:
$log.info("Due to exception '#{ex}' the current browser is being restarted")
@browser = EHR::BrowserSettings.restart_browser
sleep 10
@browser.navigate.to(DESKTOP_APP_URL)
sleep 3
此后,将执行登录脚本。如何解决错误?
答案 0 :(得分:0)
不确定您是否使用watir-webdriver,但您可以尝试:
@browser.close
@browser = Watir::Browser.new
答案 1 :(得分:0)
No actually the script is After block :
if scenario.failed?
$log.info("Due to exception the current browser is being restarted")
@browser = nil
@browser = EHR::BrowserSettings.restart_browser
@browser.navigate.to(DESKTOP_APP_URL)
.....
this script is working (its relaunching the browser with the given URL).
Im trying to close the browser window in at_exit() hook and here im not able to get the @browser object value and hence could not close the browser.
I jst need to close it in the at_exit block. Is there any way to do it.