退出浏览器会话& relogin-量角器

时间:2017-03-08 06:23:53

标签: javascript session selenium-webdriver jasmine protractor

我正在尝试关闭浏览器,然后重新登录&断言在webapp上完成的设置。但每次我关闭浏览器&尝试重新打开它失败与新实例交互。

以下是我尝试的两种方式的代码段: 第一个代码片段:通过browser.restart& browser.get api's 第二个代码片段:通过Forknewdriver会话实例

browser.quit();
browser.restart(); 
browser.get("http://testurl.com");
var username = element(by.id('txtEMAIL'));
username.sendKeys("user");
browser.sleep(4000).then(function(){ console.log('Applied sleep for sometime');});
var pwd = element(by.id('pwd'));
pwd.sendKeys("password");
browser.sleep(4000).then(function(){ console.log('Applied sleep for sometime');});
var submitbtn = element(by.id('submit'));
submitbtn.click() ;


var browser2 = browser.forkNewDriverInstance(true);
browser2.waitForAngular();
var element2 = browser2.element;
browser2.waitForAngular();
browser2.get("http://testurl.com");
var username2 = element2(by.id('txtEMAIL'));
username2.sendKeys("user");
browser2.sleep(4000).then(function(){ console.log('Applied sleep for sometime');});
var pwd2 = element2(by.id('pwd'));
pwd2.sendKeys("password");
browser2.sleep(4000).then(function(){ console.log('Applied sleep for sometime');});
var submitbtn2 = element2(by.id('submit'));
submitbtn2.click();

有什么建议吗?

Error Trace:
Failures:
   Message:
 [31m    Failed: Error while running testForAngular: Page reload detected during async script (WARNING: The server did not provide any stacktrace information)
     Command duration or timeout: 1.88 seconds
     Driver info: org.openqa.selenium.ie.InternetExplorerDriver
     Capabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:17489/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]
     Session ID: b1a8546b-fbb9-4844-8be7-836c324a202b[0m
   Stack:
     Error: Error while running testForAngular: Page reload detected during async script (WARNING: The server did not provide any stacktrace information)
     Command duration or timeout: 1.88 seconds
     Build info: version: '3.1.0', revision: '86a5d70', time: '2017-02-16 07:57:44 -0800'
     Driver info: org.openqa.selenium.ie.InternetExplorerDriver
     Capabilities [{browserAttachTimeout=0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, pageLoadStrategy=normal, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:17489/, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss}]
     Session ID: b1a8546b-fbb9-4844-8be7-836c324a202b
         at executeAsyncScript_.then (C:\Protractor\node_modules\protractor\lib\browser.ts:944:27)
         at ManagedPromise.invokeCallback_ (C:\Protractor\node_modules\selenium-webdriver\lib\promise.js:1366:14)
         at TaskQueue.execute_ (C:\Protractor\node_modules\selenium-webdriver\lib\promise.js:2970:14)
         at TaskQueue.executeNext_ (C:\Protractor\node_modules\selenium-webdriver\lib\promise.js:2953:27)
         at asyncRun (C:\Protractor\node_modules\selenium-webdriver\lib\promise.js:2813:27)
         at C:\Protractor\node_modules\selenium-webdriver\lib\promise.js:676:7
         at process._tickCallback (internal/process/next_tick.js:103:7)
     From: Task: Run it("Testcase") in control flow
         at Object.<anonymous> (C:\Protractor\node_modules\jasminewd2\index.js:94:19)
         at C:\Protractor\node_modules\jasminewd2\index.js:64:48
         at ControlFlow.emit (C:\Protractor\node_modules\selenium-webdriver\lib\events.js:62:21)
         at ControlFlow.shutdown_ (C:\Protractor\node_modules\selenium-webdriver\lib\promise.js:2565:10)
         at shutdownTask_.MicroTask (C:\Protractor\node_modules\selenium-webdriver\lib\promise.js:2490:53)
         at MicroTask.asyncRun (C:\Protractor\node_modules\selenium-webdriver\lib\promise.js:2619:9)
     From asynchronous test: 
     Error
         at Suite.<anonymous> (C:\Protractor\Testcases\fvt.js:13:2)
         at Object.<anonymous> (C:\Protractor\Testcases\fvt.js:8:1)
         at Module._compile (module.js:570:32)
         at Object.Module._extensions..js (module.js:579:10)
         at Module.load (module.js:487:32)
         at tryModuleLoad (module.js:446:12)

 1 spec, 1 failure
 Finished in 54.105 seconds 

0 个答案:

没有答案