如何在 Cucumber + Selenium Webdriver + Page-Object 中重启浏览器?
How to restart browser in Cucumber + Selenium Webdriver + Page-Object?
我正在使用 Chrome 和 IE 浏览器。我需要重新启动当前浏览器并继续执行。
当我重新启动浏览器时,当前浏览器关闭并使用给定的 url 启动新浏览器但抛出此错误:
no such session (Driver info: 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
之后,将执行登录脚本。我该如何解决错误?
不确定您是否使用 watir-webdriver,但您可以尝试:
@browser.close
@browser = Watir::Browser.new
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.
我正在使用 Chrome 和 IE 浏览器。我需要重新启动当前浏览器并继续执行。 当我重新启动浏览器时,当前浏览器关闭并使用给定的 url 启动新浏览器但抛出此错误:
no such session (Driver info: 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
之后,将执行登录脚本。我该如何解决错误?
不确定您是否使用 watir-webdriver,但您可以尝试:
@browser.close
@browser = Watir::Browser.new
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.