在使用Maven和QAF的Eclipse中启动TestNG时获取NullPointerException

我的团队中现在有一个现有的自动化脚本和框架。他们使用了TestNG和Maven。

我正在收到此错误->在使用Maven和QAF的eclipse中启动TestNG时,出现“内部错误:“启动.xml”。java.lang.NullPointerException”

我尝试在Google上进行搜索,并尝试应用可能的解决方案,但仍然收到相同的错误:

以下是代码:

功能文件

@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)

This is the Eclipse Version

This is the Installed Software

希望您能考虑到。我对他们使用的框架是陌生的

avrilwang 回答:在使用Maven和QAF的Eclipse中启动TestNG时获取NullPointerException

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2494403.html

大家都在问