异常:会话 ID 为 null。调用 quit() 后使用 WebDriver?

Exception : Session ID is null. Using WebDriver after calling quit()?

提问人:Little girl 提问时间:11/15/2023 最后编辑:Little girl 更新时间:11/20/2023 访问量:36

问:

我正在从本地运行我的 6 个脚本到 sauce,部分我的脚本只传递了 .

Scenario 1 :- Passed
Scenario 2 :- Failed with Exception
Scenario 3 :- Passed
Scenario 4 :- Failed with Exception
Scenario 5 :- Passed
Scenario 6 :- Failed with Exception   

虽然,在我的本地机器上运行,所有脚本都通过了。 使用 Cucumber Runner 文件执行我的脚本。 我已经看到了此类问题的多个答案,其中它要求在 AFTER 方法中退出驱动程序。 我做了同样的事情,但仍然出错.

**Code :-**
Before :-
                               ` try {
                    driver = new RemoteWebDriver(new URL(SAUCE_URL), options);
                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    System.out.println("Exceptionnnnnnnnnnnnnnnnn"+e);
                    e.printStackTrace();
                }
                System.out.println("Remote Driver "+driver);
                driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
                if (System.getenv("JOB_NAME") != null) {
                    printSessionId(System.getenv("JOB_NAME"));
                } else {
                    printSessionId(jobName);
                }
                                String jobId = (((RemoteWebDriver) driver).getSessionId()).toString();
                PublicUrl = getPublicJobLink(jobId);
                System.out.println("Public Sauce URL >> " + PublicUrl);

....................................................................................................................................................................................................................................

@After
public void takescreenshot(Scenario scenario) throws Throwable {
    if (!Execution_mode.equalsIgnoreCase("API")) {
        tearDown(scenario);
        scenario.write("");
        // scenario.write(PublicUrl);
        String a = "";
        scenario.write(a);
    //  driver.close();
        driver.quit();
    }

}

出现异常错误:-

org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '4.0.0-alpha-5', revision: 'b3a0d621cc'
System info: host: 'LHTU0GY36234T7Y', ip: '10.190.230.183', 
maven selenium-webdriver cucumber saucelabs remotewebdriver

评论

0赞 Little girl 11/22/2023
有人可以帮我吗?:(

答: 暂无答案