线程“main”org.openqa.selenium.remote.SessionNotFoundException中的异常:在调用quit()后

时间:2016-09-02 17:45:54

标签: java selenium

我在200多个测试用例执行结束时遇到异常。由于这在测试套件执行的最后阶段失败 - 因此不会创建Testng报告。

尝试了所有选项 - 使用driver.quit()driver.close(),新安装的FF 45 ESR版本但没有运气!!

注意 - >在测试套件执行结束时(包含21个测试类)发生异常。

后来意识到只有一个测试用例正在抛出这个例子。 (奇怪的是它允许整个套件运行到最后)

我的测试课在这里 -

@DataProvider (name = "inputData")
    public Object[][] inputData(){

        return new Object[][] {{passwordPolicyPage.minLengthTextBox,"9"},{passwordPolicyPage.minLowerCaseTextBox,"2"},
                               {passwordPolicyPage.minSplCharsTextBox,"2"},{passwordPolicyPage.minUpperCaseTextBox,"2"},
                               {passwordPolicyPage.notLastPswdsTextBox,"2"},{passwordPolicyPage.pswdExpDaysTextBox,"2"},
                               {passwordPolicyPage.maxBadAttemptsTextBox,"2"},{passwordPolicyPage.notUsedInMonthsCaseTextBox,"2"}};
    }

    @Test(testName = "TS#-6552,TS#-6556,TS#-6549,TS#-6553,TS#-6550,TS#-6554,TS#-6551,TS#-6555,TS#-6928", groups = { "Sanity" },dataProvider = "inputData")
    public void testEditPswdPolicy(WebElement textBox, String value) {

        if (!passwordPolicyPage.checkBox.isSelected())
            CommonOperations.click(passwordPolicyPage.checkBox);
        CommonOperations.click(passwordPolicyPage.enabledEditPolicyBtn);
        CommonOperations.waitUntilElementAppears(passwordPolicyPage.editPolicyContent, driver);

        CommonOperations.enterData(textBox, value);
        CommonOperations.click(passwordPolicyPage.saveBtn);

        CommonOperations.sleep(1000);

        CommonOperations.click(passwordPolicyPage.enabledEditPolicyBtn);
        CommonOperations.waitUntilElementAppears(passwordPolicyPage.editPolicyContent, driver);

        try{
        Assert.assertEquals(CommonOperations.getValue(textBox, "value"), value, "Changes were not saved for "+CommonOperations.getValue(textBox, "class")+"!!!!");
        }catch(AssertionError e){
            CommonOperations.click(passwordPolicyPage.cancelBtn);
            CommonOperations.sleep(1000);
            Assert.assertTrue(false, "Changes were not saved for "+CommonOperations.getValue(textBox, "class")+"!!!!");
        }
    }

@AfterClass (alwaysRun = true)
    public void close(){
        try{
        driver.close();
        }catch(Exception e){

        }
    }

整个异常错误: -

  

[testng]线程“main”中的异常org.openqa.selenium.remote.SessionNotFoundException:调用quit()后无法使用FirefoxDriver。          [testng]构建信息:版本:'2.53.0',修订版:'35ae25b1534ae328c771e0856c93e187490ca824',时间:'2016-03-15 10:43:46'          [testng]系统信息:主机:'dell-PC',ip:'192.168.33.1',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version :'1.8.0_45'          [testng]驱动程序信息:driver.version:RemoteWebDriver          [testng]在org.openqa.selenium.firefox.FirefoxDriver $ LazyCommandExecutor.execute(FirefoxDriver.java:377)          [testng] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)          [testng] at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)          [testng] at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:500)          [testng]在org.openqa.selenium.By $ ByXPath.findElement(By.java:361)          [testng] at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)          [testng] at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:59)          [testng] at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:37)          [testng] at com.sun.proxy。$ Proxy11.toString(Unknown Source)          [testng] at org.testng.reporters.TestHTMLReporter.generateTable(TestHTMLReporter.java:114)          [testng] at org.testng.reporters.TestHTMLReporter.generateLog(TestHTMLReporter.java:305)          [testng] at org.testng.reporters.TestHTMLReporter.onFinish(TestHTMLReporter.java:40)          [testng] at org.testng.TestRunner.fireEvent(TestRunner.java:1241)          [testng] at org.testng.TestRunner.afterRun(TestRunner.java:1032)          [testng] at org.testng.TestRunner.run(TestRunner.java:621)          [testng] at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)          [testng] at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)          [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)          [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:240)          [testng] at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)          [testng] at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)          [testng] at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)          [testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)          [testng] at org.testng.TestNG.run(TestNG.java:1057)          [testng] at org.testng.TestNG.privateMain(TestNG.java:1364)          [testng] at org.testng.TestNG.main(TestNG.java:1333)          [testng]测试失败了。

0 个答案:

没有答案