TestNG won't detect my test or build it

I looked through my Maven plugins, structured my folders as it is supposed to be, and annotated the Test as needed. The test won't build at all. Below is the folder structure, code, and also the logs after trying to run the test.
package testCases;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Test;

import pageObjectRepository.LoginPage;
import pageObjectRepository.PageIndex;

public class LoginTest extends PageIndex{

@BeforeMethod
public void setUp() {
loginPage = new LoginPage(driver);
}

@Test(enabled = true)
public void testLogin(@Optional("admin") String username, @Optional("admin") String password) {
loginPage.login(username, password);
}

@AfterMethod
public void tearDown() {
driver.close();
driver.quit();
}
}
package testCases;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Test;

import pageObjectRepository.LoginPage;
import pageObjectRepository.PageIndex;

public class LoginTest extends PageIndex{

@BeforeMethod
public void setUp() {
loginPage = new LoginPage(driver);
}

@Test(enabled = true)
public void testLogin(@Optional("admin") String username, @Optional("admin") String password) {
loginPage.login(username, password);
}

@AfterMethod
public void tearDown() {
driver.close();
driver.quit();
}
}
cd C:\Users\ainha\Project\main; "JAVA_HOME=C:\\Program Files\\Java\\Oracle_JDK-23" cmd /c "\"C:\\Users\\ainha\\.vscode\\extensions\\oracle.oracle-java-23.0.1\\nbcode\\java\\maven\\bin\\mvn.cmd\" -Dtest=testCases.LoginTest -Dmaven.ext.class.path=C:\\Users\\ainha\\.vscode\\extensions\\oracle.oracle-java-23.0.1\\nbcode\\java\\maven-nblib\\netbeans-eventspy.jar --no-transfer-progress process-test-classes surefire:test"
Scanning for projects...

------------------------< com.automation:main >-------------------------
Building Selenium Automation Project 1.0-SNAPSHOT
from pom.xml
--------------------------------[ pom ]---------------------------------

--- surefire:3.1.2:test (default-cli) @ main ---
No tests to run.
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 0.555 s
Finished at: 2025-01-15T01:46:01+09:00
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.1.2:test (default-cli) on project main: No tests matching pattern "testCases.LoginTest" were executed! (Set -Dsurefire.failIfNoSpecifiedTests=false to ignore this error.) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
cd C:\Users\ainha\Project\main; "JAVA_HOME=C:\\Program Files\\Java\\Oracle_JDK-23" cmd /c "\"C:\\Users\\ainha\\.vscode\\extensions\\oracle.oracle-java-23.0.1\\nbcode\\java\\maven\\bin\\mvn.cmd\" -Dtest=testCases.LoginTest -Dmaven.ext.class.path=C:\\Users\\ainha\\.vscode\\extensions\\oracle.oracle-java-23.0.1\\nbcode\\java\\maven-nblib\\netbeans-eventspy.jar --no-transfer-progress process-test-classes surefire:test"
Scanning for projects...

------------------------< com.automation:main >-------------------------
Building Selenium Automation Project 1.0-SNAPSHOT
from pom.xml
--------------------------------[ pom ]---------------------------------

--- surefire:3.1.2:test (default-cli) @ main ---
No tests to run.
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 0.555 s
Finished at: 2025-01-15T01:46:01+09:00
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.1.2:test (default-cli) on project main: No tests matching pattern "testCases.LoginTest" were executed! (Set -Dsurefire.failIfNoSpecifiedTests=false to ignore this error.) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
No description
53 Replies
JavaBot
JavaBot3w ago
This post has been reserved for your question.
Hey @Ainhart! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st3w ago
Can you try just running mvn test? Can you show your pom.xml?
Ainhart
AinhartOP3w ago
PS C:\Users\ainha\Project\main> mvn test [INFO] Scanning for projects... [INFO] [INFO] ------------------------< com.automation:main >------------------------- [INFO] Building Selenium Automation Project 1.0-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ pom ]--------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.048 s [INFO] Finished at: 2025-01-15T02:26:54+09:00 [INFO] ------------------------------------------------------------------------
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.automation</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Selenium Automation Project</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

</plugins>
</pluginManagement>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.automation</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Selenium Automation Project</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

</plugins>
</pluginManagement>
</build>
</project>
dan1st
dan1st3w ago
You have both JUnit and TestNG in your dependencies. Is that intentional?
Ainhart
AinhartOP3w ago
I think I'll try removing that first
Ainhart
AinhartOP3w ago
I only need TestNG, so I removed J Unit
dan1st | Daniel
{"name":"error","attributes":{"message":"Failed to run TestNG tests","trace":"java.lang.ClassNotFoundException: testCases.LoginTest
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:578)
at java.base/java.lang.Class.forName(Class.java:557)
at com.microsoft.java.test.runner.testng.TestNGLauncher.getClassNameFromMethod(TestNGLauncher.java:57)
at com.microsoft.java.test.runner.testng.TestNGLauncher.parse(TestNGLauncher.java:43)
at com.microsoft.java.test.runner.testng.TestNGLauncher.execute(TestNGLauncher.java:32)
at com.microsoft.java.test.runner.Launcher.main(Launcher.java:57)
"}}
{"name":"error","attributes":{"message":"Failed to run TestNG tests","trace":"java.lang.ClassNotFoundException: testCases.LoginTest
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:578)
at java.base/java.lang.Class.forName(Class.java:557)
at com.microsoft.java.test.runner.testng.TestNGLauncher.getClassNameFromMethod(TestNGLauncher.java:57)
at com.microsoft.java.test.runner.testng.TestNGLauncher.parse(TestNGLauncher.java:43)
at com.microsoft.java.test.runner.testng.TestNGLauncher.execute(TestNGLauncher.java:32)
at com.microsoft.java.test.runner.Launcher.main(Launcher.java:57)
"}}
This message has been formatted automatically. You can disable this using /preferences.
Ainhart
AinhartOP3w ago
I am getting this instead now
dan1st
dan1st3w ago
Can you show the full output of mvn test again? or better mvn clean test
Ainhart
AinhartOP3w ago
PS C:\Users\ainha\Project\main> mvn test [INFO] Scanning for projects... [INFO] [INFO] ------------------------< com.automation:main >------------------------- [INFO] Building Selenium Automation Project 1.0-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ pom ]--------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.049 s [INFO] Finished at: 2025-01-15T02:55:03+09:00 [INFO] ------------------------------------------------------------------------
dan1st
dan1st3w ago
What's your current pom.xml?
Ainhart
AinhartOP3w ago
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.automation</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Selenium Automation Project</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

</plugins>
</pluginManagement>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.automation</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Selenium Automation Project</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

</plugins>
</pluginManagement>
</build>
</project>
dan1st
dan1st3w ago
You probably want <scope>test</scope> for the test dependencies (TestNG and Selenium)
dan1st
dan1st3w ago
Stack Overflow
Testng test are ignored after upgrading to Sprint Boot 3 and maven-...
I have an application that was executing TestNG tests perfectly with maven, for example, when using a mvn clean install command. Currently I have updated the application to start using Spring Boot ...
dan1st
dan1st3w ago
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
</plugin>
Ainhart
AinhartOP3w ago
so I updated that to include <scope>test</scope> and the dependency as well But the scope tag broke my Selenium import
Ainhart
AinhartOP3w ago
No description
dan1st
dan1st3w ago
Is that code supposed to be used outside tests?
Ainhart
AinhartOP3w ago
I have POM java classes that are using Selenium
dan1st
dan1st3w ago
idk what that means
Ainhart
AinhartOP3w ago
They are classes representing Pages
dan1st
dan1st3w ago
but if you want to use Selenium from files in src/main/java, you shouldn't use <scope>test</scope> for selenium
Ainhart
AinhartOP3w ago
Alright, got it
dan1st
dan1st3w ago
and why are they in src/main/java and not src/test/java? Is the project supposed to test another project?
Ainhart
AinhartOP3w ago
No, but that's the recommended structure. The POM objects uses Selenium keywords to identify elements in the web page for easier management
dan1st
dan1st3w ago
What do you8 mean with POM objects? I assume you are not talking about project object model?
Ainhart
AinhartOP3w ago
Page Object Model
Ainhart
AinhartOP3w ago
BrowserStack
Page Object Model and Page Factory in Selenium | BrowserStack
Understand the fundamental concept of Page Object Model (POM) and Page factory in Selenium along with the example and key differences.
Ainhart
AinhartOP3w ago
package pageObjectRepository;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class MainPage {

WebDriver driver;

// Constructor to initialize WebDriver
public MainPage(WebDriver driver) {
this.driver = driver;
}

@FindBy(id = "do1")
private By do1Button;

@FindBy(id = "do2")
private By do2Button;

@FindBy(id = "textFontSize")
private By textFontSize;

@FindBy(id = "btnIncreaseFont")
private By btnIncreaseFont;

@FindBy(id = "btnDecreaseFont")
private By btnDecreaseFont;

@FindBy(id = "bgColor")
private By bgColorInput;

@FindBy(id = "btnSetBgColor")
private By setBgColorButton;

@FindBy(id = "formToColorize")
private By formToColorize;

public void clickDo1Button() {
driver.findElement(do1Button).click();
}

public void clickDo2Button() {
driver.findElement(do2Button).click();
}

public void clickIncreaseFontButton() {
driver.findElement(btnIncreaseFont).click();
}

public void clickDecreaseFontButton() {
driver.findElement(btnDecreaseFont).click();
}

public void setBackgroundColor(String color) {
WebElement input = driver.findElement(bgColorInput);
input.sendKeys(color);
driver.findElement(setBgColorButton).click();
}

// Methods to get element values
public String getFontSize() {
return driver.findElement(textFontSize).getCssValue("font-size");
}

public String getFormBackgroundColor() {
return driver.findElement(formToColorize).getCssValue("background-color");
}

public boolean isDo1ButtonEnabled() {
return driver.findElement(do1Button).isEnabled();
}

public boolean isDo2ButtonEnabled() {
return driver.findElement(do2Button).isEnabled();
}
}
package pageObjectRepository;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class MainPage {

WebDriver driver;

// Constructor to initialize WebDriver
public MainPage(WebDriver driver) {
this.driver = driver;
}

@FindBy(id = "do1")
private By do1Button;

@FindBy(id = "do2")
private By do2Button;

@FindBy(id = "textFontSize")
private By textFontSize;

@FindBy(id = "btnIncreaseFont")
private By btnIncreaseFont;

@FindBy(id = "btnDecreaseFont")
private By btnDecreaseFont;

@FindBy(id = "bgColor")
private By bgColorInput;

@FindBy(id = "btnSetBgColor")
private By setBgColorButton;

@FindBy(id = "formToColorize")
private By formToColorize;

public void clickDo1Button() {
driver.findElement(do1Button).click();
}

public void clickDo2Button() {
driver.findElement(do2Button).click();
}

public void clickIncreaseFontButton() {
driver.findElement(btnIncreaseFont).click();
}

public void clickDecreaseFontButton() {
driver.findElement(btnDecreaseFont).click();
}

public void setBackgroundColor(String color) {
WebElement input = driver.findElement(bgColorInput);
input.sendKeys(color);
driver.findElement(setBgColorButton).click();
}

// Methods to get element values
public String getFontSize() {
return driver.findElement(textFontSize).getCssValue("font-size");
}

public String getFormBackgroundColor() {
return driver.findElement(formToColorize).getCssValue("background-color");
}

public boolean isDo1ButtonEnabled() {
return driver.findElement(do1Button).isEnabled();
}

public boolean isDo2ButtonEnabled() {
return driver.findElement(do2Button).isEnabled();
}
}
Here's an example
dan1st
dan1st3w ago
So the project you are working on is supposed testing a website that isn't in this project?
Ainhart
AinhartOP3w ago
Yeah it's an external webpage
dan1st
dan1st3w ago
ok yeah then it's fine So what happens now? With you adding surefire-testng
Ainhart
AinhartOP3w ago
It still doesn't work
dan1st
dan1st3w ago
Does mvn clean test still give you the same output? Can you show your new pom.xml?
Ainhart
AinhartOP3w ago
Yep
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.automation</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Selenium Automation Project</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

</plugins>
</pluginManagement>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.automation</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Selenium Automation Project</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

</plugins>
</pluginManagement>
</build>
</project>
dan1st
dan1st3w ago
you could try updating your versions I guess specifically of surefire, surefire-testng and testng oh and I think you shoulod use the same version for the maven-surefire-plugin and surefire-testing so 3.5.2 in both cases
Ainhart
AinhartOP3w ago
Still not working
dan1st
dan1st3w ago
What's the output of mvn clean compiler:test-compile surefire:test?
Ainhart
AinhartOP3w ago
[INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.159 s [INFO] Finished at: 2025-01-15T03:24:41+09:00 [INFO] ------------------------------------------------------------------------ [ERROR] Could not find goal 'test-compile' in plugin org.apache.maven.plugins:maven-compiler-plugin:3.11.0 among available goals compile, help, testCompile -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException
dan1st
dan1st3w ago
ok, should be mvn clean compiler:testCompile surefire:test But please actually show the full output and not just the end
Ainhart
AinhartOP3w ago
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.automation:main >-------------------------
[INFO] Building Selenium Automation Project 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- clean:3.4.0:clean (default-clean) @ main ---
[INFO] Deleting C:\Users\ainha\SecuritizeAssignment\main\target
[INFO]
[INFO] --- compiler:3.11.0:testCompile (default-cli) @ main ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 1 source file with javac [debug release 17] to target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.492 s
[INFO] Finished at: 2025-01-15T03:25:55+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:testCompile (default-cli) on project main: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.automation:main >-------------------------
[INFO] Building Selenium Automation Project 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- clean:3.4.0:clean (default-clean) @ main ---
[INFO] Deleting C:\Users\ainha\SecuritizeAssignment\main\target
[INFO]
[INFO] --- compiler:3.11.0:testCompile (default-cli) @ main ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 1 source file with javac [debug release 17] to target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.492 s
[INFO] Finished at: 2025-01-15T03:25:55+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:testCompile (default-cli) on project main: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
This is the full output
dan1st
dan1st3w ago
oh wait I noticed something You used <pluginManagement> put the surefire plugin into <build><plugins> also that error tells you what the issue is
Ainhart
AinhartOP3w ago
No compiler? Huh?
dan1st
dan1st3w ago
You need to run on a JDK Do you have a JDK installed? What's the output of javac --version? ohhhhh you have <packaging>pom</packaging> remove that <packaging>pom</packaging> means you don't have any Java code
Ainhart
AinhartOP3w ago
Ok, let me fix that javac --version javac 23.0.1 So I fixed that
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.automation</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.5.2</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

</plugins>
</pluginManagement>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.automation</groupId>
<artifactId>main</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.12.0</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.8.0</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.5.2</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

</plugins>
</pluginManagement>
</build>
</project>
This is my current POM
Ainhart
AinhartOP3w ago
That's my log now I don't see why the package does not exist
dan1st
dan1st3w ago
Can you run mvn test now that's probably because it's compiling tests without main sources that one looks like you still had <packaging>pom</packaging> though
JavaBot
JavaBot3w ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Ainhart
AinhartOP2w ago
I already removed this one Sorry, I don't know what this quite means, could you explain? I already compiled the main source but this still occurs It's ok, I got it figured out, thanks
JavaBot
JavaBot2w ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot2w ago
Post Closed
This post has been closed by <@82285533308399616>.

Did you find this page helpful?