Closed SQALeaders closed 4 years ago
Please dont close without resolved. I have to create new issue again and again
@SQALeaders - We can either work on getting your issue resolved by you doing what I am requesting you to do viz., provide a simple standalone example that can reproduce the problem.
But if you aren't going to provide that, and still want to keep your issue open, there's not much that can be done, but just leave the issue as is.
Duplicates https://github.com/cbeust/testng/issues/2225
One page class is missing please include this for first home page login button
public class WPHomePage {
WebDriver driver;
public WPHomePage(WebDriver ldriver) {
this.driver = ldriver;
}
@FindBy(xpath="//*[@id='lpc-header-nav']/div/div/div[1]/header/nav/ul[2]/li[1]/a")
@CacheLookup
WebElement Login;
public void ClickLogin()
{
Login.click();
}
Also utility classes
public class ListenerImp implements ITestListener {
@Override
public void onStart (ITestContext results){
System.out.println("Starts test execution "+results.getName());
}
@Override
public void onFinish (ITestContext results){
System.out.println("Finish test execution "+results.getName());
}
@Override
public void onTestStart(ITestResult results){
System.out.println("Test Started "+results.getName());
}
@Override
public void onTestSkipped(ITestResult results) {
System.out.println("Test Started " + results.getName());
}
@Override
public void onTestSuccess(ITestResult results) {
System.out.println("Test Started " + results.getName());
}
@Override
public void onTestFailure(ITestResult results) {
System.out.println("Test Started " + results.getName());
}
@Override
public void onTestFailedButWithinSuccessPercentage (ITestResult results) {
System.out.println("Test Started " + results.getName());
}
public class ReadConficFile {
Properties Pro;
public ReadConficFile() {
try {
File Src=new File("C:\\Users\\sivasothywaran\\IdeaProjects\\FullStackDT\\Config.property");
FileInputStream fis=new FileInputStream(Src);
Pro = new Properties();
Pro.load(fis);
} catch (Exception e) {
e.printStackTrace();
}
}
public String GetCromePath()
{
//String ChromePath = Pro.getProperty("ChromeDriver");
//return ChromePath;
return Pro.getProperty("ChromeDriver");
}
public String GetGeckoPath()
{
//String ChromePath = Pro.getProperty("FirefoxDriver");
//return ChromePath;
return Pro.getProperty("FirefoxDriver");
}
public String GetEdgePath()
{
//String EdgePath = Pro.getProperty("EdgeDriver");
//return EdgePath;
return Pro.getProperty("EdgeDriver");
}
public String GetIEPath()
{
System.out.println("Configread reached");
//String EdgePath = Pro.getProperty("IE");
//return EdgePath;
return Pro.getProperty("IEDriver");
}
public String GetURL()
{
//String url = Pro.getProperty("URL");
//return url;
return Pro.getProperty("URL");
}
public String GetBrowser()
{
//String url = Pro.getProperty("Browser");
//return url;
return Pro.getProperty("Browser");
}
public String GetExcelData()
{
return Pro.getProperty("ExcelFile");
}
}
public class ReadExcelData {
XSSFWorkbook wb;
XSSFSheet Sheet;
public ReadExcelData (String ExcelPath)
{
try
{
File SRC=new File(ExcelPath);
FileInputStream FIS=new FileInputStream(SRC);
wb=new XSSFWorkbook(FIS);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
public String Getdata(String SheetName, int Row, int Column){
Sheet=wb.getSheet("ValidLogin");
String data = Sheet.getRow(Row).getCell(Column).getStringCellValue();
return data;
}
public int GetRowCount(String SheetName){
int RowCount=wb.getSheet(SheetName).getLastRowNum();
RowCount=RowCount+1;
return RowCount;
}
@juherr - Do you want to help explain to @SQALeaders perhaps :) ? I am not sure if what I am asking for is being accepted here!
ok wait i will create another project simple
I created the below code. Now I get org.testng.internal.reflect.MethodMatcherException: I couldnt pass the browser parameter. Any suggestions
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.*;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
public class RIssueSimple {
WebDriver driver;
@Test (dataProvider = "WPData")
@Parameters ("OBrowser")
public void LoginWP(String browserName, String UserName, String PWord) throws Exception {
if (browserName.equalsIgnoreCase("firefox"))
{
System.setProperty("webdriver.gecko.driver", "C:\\Users\\sivasothywaran\\Desktop\\SQA\\Selenium testing\\Driver\\geckodriver.exe");
driver=new FirefoxDriver();
}
else if (browserName.equalsIgnoreCase("Chrome"))
{
System.setProperty("webdriver.chrome.driver", "C:\\Users\\sivasothywaran\\Desktop\\SQA\\Selenium testing\\Driver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
}
driver.manage().window().maximize();
Thread.sleep(5000);
driver.get("https://wordpress.com");
driver.findElement(By.xpath("//*[@id='lpc-header-nav']/div/div/div[1]/header/nav/ul[2]/li[1]/a")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='usernameOrEmail']")).sendKeys(UserName);
driver.findElement(By.xpath("//*[@id='primary']/div/main/div/div[1]/div/form/div[1]/div[2]/button")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='password']")).sendKeys(PWord);
driver.findElement(By.xpath("//*[@id='primary']/div/main/div/div[1]/div/form/div[1]/div[2]/button")).click();
}
@DataProvider(name ="WPData")
public Object[][] PassData() throws Exception {
File SRC = new File("C:\\Users\\sivasothywaran\\Desktop\\SQA\\Selenium testing\\DataDriven\\ExcelFiles\\WPLoginData.xlsx");
FileInputStream FIS = new FileInputStream(SRC);
XSSFWorkbook wb = new XSSFWorkbook(FIS);
XSSFSheet Sheet = wb.getSheet("ValidLogin");
int RowCount = wb.getSheet("ValidLogin").getLastRowNum();
RowCount = RowCount + 1;
Object[][] Data= new Object[RowCount][2];
for (int i = 0; i < RowCount; i++) {
Data[i][0] = Sheet.getRow(i).getCell(0).getStringCellValue();
Data[i][1] = Sheet.getRow(i).getCell(1).getStringCellValue();
}
return Data;
}
@AfterMethod
public void TearDown() throws InterruptedException {
if (driver == null)
return;
driver.quit();
}
}
TestNG.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite" parallel="tests">
<test name = "Chrome">
<parameter name = "OBrowser" value="chrome" />
<classes>
<class name="RIssueSimple"></class>
</classes>
</test>
<test name = "firefox">
<parameter name = "OBrowser" value="firefox" />
<classes>
<class name="RIssueSimple"></class>
</classes>
</test>
</suite>
@SQALeaders - AFAIK you cannot combine @Parameters
and data provider. Both these mechanisms are meant to be to support data driven testing. You should use only one of them.
This sample that you shared still depends on a whole bunch of external things
So unless and until you can help share a sample that we can use to recreate the issue, there's not much that can be done here!
Thank you for your response and time. Yes, that's why I'm not able to give you a standalone one, I cant pass both parameters, if I don't pass browser as well as excel-sheet, I can't reproduce the same scenario. Because the issue is when we do a parallel cross-browser test for the class which use data provider. Regarding the excel sheet, it's just a 2-row excel sheet as below. The first column is a user name and the last column is a password. Regarding URL its a common blog website "https://wordpress.com"
vidawaran | Vagini_10 krishna4kidsbrain | Sivagi_10
Once again the issue I have is, I can't do a parallel cross-browser test using TestNG.xml when I use data provider in my test class.
@SQALeaders
Please note that even @cbeust echoes the same ask as me.
We need a sample without selenium dependency to prove that this issue is indeed a TestNG problem.
Your stack trace shows no traces of TestNG but clearly shows it to be either a test case problem or a selenium problem.
Thank you. The reason for the issue was my browser was static. public class BrowserFactory { static WebDriver driver; public static WebDriver startBrowser(String browserName, String url) throws InterruptedException
Solution and make the browser non-static
TestNG Version
Expected behavior
When creating Data-driven framework with the TestNG dataProvider, Not able to do cross-browser testing in parallel with the TestNG XML file. If I remove Parallel works fine. But if I try to do parallel TestNG provide one data for browser then second data for the next browser and throws an error
TestNG Version - 7.1.0 Expected behavior If I have 10 data in excel file TestNG should run all 10 for each browser. Example if I run Chrome and Firefox both browsers should run all 10 data
Actual behavior TestNG gives first data for Chrome, second data for Firefox and throw error
org.openqa.selenium.ElementNotInteractableException: element not interactable
.Is the issue reproductible on runner?
Maven IntelliJ Test case sample Testcase to verify valid login
The base class:
Page Class
XML (TestNG.xml)
Error message: