我的团队现在有一个现有的自动化脚本和框架。他们使用了 TestNG 和 Maven。
我收到此错误->“在使用 Maven 和 QAF 的 Eclipse 中启动 TestNG 时发生内部错误:“启动 .xml”。java.lang.NullPointerException”
我试图在谷歌上搜索它并尝试应用可能的解决方案但仍然得到同样的错误:
这是代码:
特征文件
@FEAT-001
Scenario Outline: [FEAT-001]Verify the ID Declaration
@FEAT-001-1
Given I open ID page
And I login using code "<Code>" credentials
And list should still be displayed
And I click the "<Name>" in the Name field for application
And I go to Agreements
And I verify web element "DoYouHaveAnyID.text" is presented
步骤定义文件
public class commonstep {
public static final int WAIT_TIME_MAX = 50000 ;
public static final int WAIT_TIME = 1000 ;
public static final int WAIT_SHORT_TIME = 10000 ;
public static final int WAIT_LONG_TIME = 30000 ;
@QAFTestStep(description = "I open ID page")
public void iOpenIDpage(){
String env_run ;
String url ;
env_run = getBundle().getPropertyValue("env") ;
switch(env_run) {
case "qa":
url = getBundle().getPropertyValue("env.baseurl.qa") ;
break;
case "uat":
url = getBundle().getPropertyValue("env.baseurl.uat") ;
break;
case "dev":
default:
url = getBundle().getPropertyValue("env.baseurl.dev") ;
break;
}
WebDriver browser = new WebDriverTestCase().getDriver() ;
WebDriverWait wait = new WebDriverWait(browser, 120);
browser.get(url + "List");
wait.until(invisibilityOfElementLocated(By.cssSelector("div#pre-loading")));
wait.until(visibilityOfElementLocated(className("btn-add")));
wait.until(visibilityOfElementLocated(className("mat-card")));
wait.until(ExpectedConditions.visibilityOfElementLocated(className("icon")));
QAFExtendedWebElement divIcon = new QAFExtendedWebElement(By.cssSelector("mat-toolbar .mat-icon-button"));
divIcon.click();
}
POM.xml
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.company.ap</groupId>
<artifactId>project-id-automation</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>ui-tests-sample</artifactId>
<name>ui-tests-sample</name>
<url>http://maven.apache.org</url>
<properties>
<testngXmlDir>src/main/resources/config</testngXmlDir>
<resourcesDir>src/main/resources</resourcesDir>
<chromeDriverPath>${resourcesDir}/driver/chromedriver.exe</chromeDriverPath>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
<systemPropertyVariables>
<application.properties.file>src/main/resources/application.properties</application.properties.file>
<env.resources>${resourcesDir}/web;${resourcesDir}/driver</env.resources>
<webdriver.chrome.driver>${chromeDriverPath}</webdriver.chrome.driver>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>${testngXmlDir}/${testngXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.company.ap</groupId>
<artifactId>ui-core-sample2</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.company.ap</groupId>
<artifactId>ui-core-sample</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
异常堆栈跟踪:
java.lang.NullPointerException
at org.testng.eclipse.maven.MavenTestNGLaunchConfigurationProvider.getEnvironment(MavenTestNGLaunchConfigurationProvider.java:69)
at org.testng.eclipse.launch.TestNGLaunchConfigurationDelegate.getEnvironment(TestNGLaunchConfigurationDelegate.java:344)
at org.testng.eclipse.launch.TestNGLaunchConfigurationDelegate.launchTypes(TestNGLaunchConfigurationDelegate.java:158)
at org.testng.eclipse.launch.TestNGLaunchConfigurationDelegate.launch(TestNGLaunchConfigurationDelegate.java:84)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
我希望你的考虑。我是他们使用的框架的新手