I'm writting some testCases on Windows in java using eclipse IDE, version : 2019-06 (4.12.0), selenium WebDriver 4.0.0, testNG 7.0.0-beta7 and PageFactory POM.
I can't build my test case in eclipse or in cmd line, because eclipse doesn't recognized my import of testNg libraries. TestNG is well installed on my project.
I'm supposed that is a class path issue. I would like to know if it's because i'm not using Maven (I don't have to used it for the moment), or if there is some issues with the latest version of testNG lib ?
My java test using testNG.xml worked perfeclty in eclipse with my testNg version: 6.14. I tried to execute it with my cmd line, I had a NullPointerError error. There was a bug with this exception in the previous versions of testNG: https://github.com/cbeust/testng/pull/1811 and they fixed it on the latest version (7.0.0).
I installed the new version of testNG, and test everything I found on the web, but nothing worked. I can't build my test anymore.
CreateSingleOrder_BondsPage.java
import org.openqa.selenium.Keys;
public class CreateSingleOrder_BondsPage {
WebDriver driver;
public CreateSingleOrder_BondsPage(WebDriver driver) {
// TODO Auto-generated constructor stub
this.driver = driver;
}
@FindBy(id="M1_3") WebElement tabOrderManagement;
public void hoverTabOrderManagement() {
Actions action = new Actions(driver);
action.moveToElement(tabOrderManagement).perform(); //move
to the element
}
}
CreateSingleOrder_BondsTest.java
import org.testng.annotations.Test;
public class CreateSingleOrder_BondsTest extends BasicTest { /*BasicTest
contains initialization of driver in @BeforeMethod and @AfterMethod also
*/
@Test
public void buyBonds() throws Exception {
CreateSingleOrder_BondsPage createBonds =
PageFactory.initElements(driver, CreateSingleOrder_BondsPage.class);
Thread.sleep(1000); //loading data
createBonds.hoverTabOrderManagement();
}
}
I have these errors :
for my import in my java class.
The import org.testng cannot be resolved
when I runned my TestNG.xml as "TestNG Suite"
An internal error occurred during: "Launching Test2 TAP_TestNG.xml". java.lang.NullPointerException
in the tab "Problems" of eclipse
Invalid classpath container: 'TestNG' in project 'Test2 TAP' - Test2 TAP -Build path - Build Path Problem
If anyone can help me with the idea of using maven for the class path, if it's could be a solution or other solutions I can use to run my test again would be very helpful.
Thanks for your help.