我的问题是我想运行两套测试。当第二套测试开始时,我得到错误:
Server Exception: sessionId should not be null; has this session been started yet?
我的 Testng.xml 文件如下所示:
<suite name="Suite" parallel="false">
<suite-files>
<suite-file path="testng1.xml"/>
<suite-file path="testng2.xml"/>
</suite-files>
</suite>
我应该提到 testng1 和 testng2 文件中的每个类都有一个@BeforeSuite
调用 setUp 方法的注释,如下所示:
public void setUp() {
String url = mySelSetter.url;
String browser = mySelSetter.browser;
if (selenium == null) {
selenium = new DefaultSelenium("localhost", 4445, browser, url);
selenium.start();
selenium.open(url);
System.out.println("A browser instance opens.");
} else {
System.out.println("A browser instance is already open.");
}
}