我需要在我的测试中创建一个新的 Protractor session 。
我试过:
browser.get()
browser.quit()
browser.get()
但它返回一个错误:
Failed: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
我也尝试使用 browser.createSession(),但它返回给我:
has no method 'createSession'
所以,我需要类似 restartBrowserBetweenTests 选项的东西,但我想调用测试的任何部分。先感谢您。
最佳答案
根据Using Multiple Browsers in the Same Test ,你可以 fork 一个新的驱动程序实例:
If you are testing apps where two browsers need to interact with each other (e.g. chat systems), you can do that with protractor by dynamically creating browsers on the go in your test. Protractor exposes a function in the browser object to help you achieve this:
browser.forkNewDriverInstance(opt_useSameUrl, opt_copyMockModules)
. Calling this will return a new independent browser object.
newBrowser = browser.forkNewDriverInstance();
browser.driver.createSession()
也可能是相关的,具体取决于您要完成的任务。
关于angularjs - 如何使用新 session 重新启动 Protractor 实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29143729/