Chrome 或 Firefox 没有使用 Maven 启动并跳过测试,没有显示错误并且发现 maven 构建成功

问题描述 投票:0回答:0

我无法启动我的测试跳过且未显示任何错误的浏览器

public class BasePage{

public static WebDriver driver;

public void WebDriver initalizeDriver(String browserType){

try{
    switch(browserType){
       case "Chrome":
         System.out.println("selecting chrome");
         WebDriverManager.chromedriver.setup();
         driver = new ChromeDriver();
         break;
       case "Firefox":
         System.out.println("selecting firefox");
         WebDriverManager.firefoxdriver.setup();
         driver = new FirefoxDriver();
         break;
         }
         driver.manage.deleteAllCookies();
         driver.manage.window.maximize();
     }
         driver.get("https://www.spicejet.com")

   }catch(Exception e){
System.out.println("Error is =>"e.getMessage());
   }

return driver;

}

当我运行脚本时,它通过 TestNG.xml 运行良好。但是当我通过 cmd 行时 我没有收到任何错误,脚本会打印 Chrome 但不会调用或启动 Chrome 浏览器

我在 pom.xml 中使用以下依赖项

<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
        <includes>
           <include>testRunner.TestRunner</include>
        </includes>
    </configuration>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>5.3.2</version>
</dependency>
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.1.0</version>
    <scope>test</scope>
</dependency>

java maven testng pom.xml webdriver-manager
© www.soinside.com 2019 - 2024. All rights reserved.