Closed rcrtwork closed 7 years ago
Not a TestNG issue. Please, post on stackoverflow instead.
The problem is in your test code and has got nothing to do with TestNG.
Selenium_Grid_Excel.setup()
you are basically initializing your excel sheet logic using ExcelUtility.setExcelFile(ExcelConstants.File_Path + ExcelConstants.File_Name, "LoginTests");
Selenium_Grid_Excel.dataProvider()
, you are assuming that there will be a valid ExcelWSheet
available. But in your case, it looks like ExcelWSheet
is null and you cannot iterate over a null object.You need to fix this in your code by starting here
java.lang.NullPointerException
at utilities.ExcelUtility.findCells(ExcelUtility.java:70)
at utilities.ExcelUtility.getTestData(ExcelUtility.java:40)
at classes.Selenium_Grid_Excel.dataProvider(Selenium_Grid_Excel.java:92)
Hi Maha, Thanks for your reply.
I initialized the ExcelUtility.setExcelFile(ExcelConstants.File_Path + ExcelConstants.File_Name, "LoginTests"); inside my dataProvider() class and now it is working fine with node(different machine in the network) and Hub in the server. Now i am able to see the test running successfully in the node machine and got the results.
Once again, Thanks Mahadevan.
Hi Mahadevan,
I am having same problem, could you post the screenshot of how you corrected yours.
@Adminsa1 - I wasn't having the issue to begin with. I was only solving someone else's issue. You can start off by posting your query on the testng-users google groups
I am having the same problem ,org.testng.TestNGException
Please explain it properly bcz i m executing it by using supporting tool Maven and Frame work is Data driven
@Somupatil,
You haven't shown us the test code, the exception nor have you told us what version are you working with.
Without any of this, what do you expect as explanations ?
I would instead recommend that you post your query on the testng-users Google forum including all of the details that I mentioned above.
We use GITHUB to typically track bugs or feature requests. In your case we are yet to even figure out if it's either of them. So the Google forum will be a good start.
--
Thanks & Regards Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!" My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
Hi All, I have written the code for login Error.txt
Homepage
package com.test.automatiom.mfb.uIActios;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;
import com.test.automation.mfb.testbase.TestBase;
public class HomePage extends TestBase {
public static final Logger log = Logger.getLogger(HomePage.class.getName());
WebDriver driver;
@FindBy(id="login")
WebElement Login;
@FindBy(xpath="//*[@id='txtFullName']")
WebElement Username;
@FindBy(xpath="//*[@id='txtPassword']")
WebElement Password;
@FindBy(xpath="//*[@id='sign_in']")
WebElement Submit;
public HomePage(WebDriver driver) {
PageFactory.initElements(driver,this);
}
public void loginApplication(String emailaddress,String password){
Login.click();
log.info("Click on signin object is :"+Login.toString());
// log.info("meassage from my number:"+Login.toString());
Username.sendKeys(emailaddress);
log.info("Enter Emailsddress :"+Username.toString());
Password.sendKeys(password);
log.info("Enter Password :"+Password.toString());
Submit.click();
log.info("Click on Submit :"+Submit.toString());
}
}
TestBase
package com.test.automation.mfb.testbase;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Reporter;
import com.test.automation.excelReader.ExcelReader;
public class TestBase {
public static final Logger log = Logger.getLogger(TestBase.class.getName());
public WebDriver driver;
// String Url = "https://www.myfundbucket.com/";
String Url = "https://www.myfundbucket.com/";
// String Browser = "firefox";
String Browser ="chrome";
public void init() {
SelectBrowser(Browser);
getUrl(Url);
}
public void SelectBrowser(String Browser) {
if (Browser.equalsIgnoreCase("firefox")) {
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "/driver/geckodriver.exe");
log.info("creating the object of this browser" + Browser);
driver = new FirefoxDriver();
} else if (Browser.equalsIgnoreCase("chrome")) {
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/driver/chromedriver.exe");
log.info("creating the object of this browser" + Browser);
driver = new ChromeDriver();
}
}
public void getUrl(String Url) {
driver.get(Url);
log.info("navigating to Url" + Url);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);}
public String[][] getdata(String sheetName, String excelName) {
String path = System.getProperty("user.dir")+"src\\main\\java\\com\\test\\automation\\mfb\\data"+excelName;
ExcelReader excel = new ExcelReader(path);
String[][] data = excel.getDataFromSheet(sheetName, excelName);
return data;
}
}
Test Class to run
package com.test.automation.mfb.homePage;
import org.apache.log4j.Logger;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.test.automatiom.mfb.uIActios.HomePage;
import com.test.automation.mfb.testbase.TestBase;
public class TC003_Login extends TestBase{
public static final Logger log = Logger.getLogger(TC003_Login.class.getName());
HomePage homepage;
@DataProvider(name = "loginData")
public String[][] getTestData() {
String[][] testRecords = getdata("logindata", "Testdata.xlsx");
return testRecords;
}
@BeforeTest
public void setup() {
init();
}
@Test(dataProvider = "loginData")
public void testLogin(String EmailAddress, String Password) {
log.info("...starting verifying login for different cerdentials");
homepage = new HomePage(driver);
homepage.loginApplication(EmailAddress,Password);
log.info("....finished verifying login for different credentials.....");
}
}
@Somupatil - As I mentioned before, you should be posting this as a question on the TestNG users google forum.
The problem is in your test code. Your @DataProvider
annotated method must either return an Iterator<Object[]>
(or) Object[][]
. Your data provider is returning back a 2D String array.
@krmahadevan In fact, I think it should work with a 2D string array. And if not, the error message could be more explicit.
@juherr - Yes you were right. It does work. My bad. Thanks for correcting me.
@Somupatil - You are working with TestNG 6.12.0. I would request you to please upgrade to the latest released version viz., 6.14.3
and try again. If its still a problem, please create a new issue, and attach a sample that can be used to reproduce the problem (Please keep the sample simple, and not include any reference to any other library. It would be great if you could just use core java to create the sample)
hi, can you please tell me the how can i solve this error
org.testng.TestNGException: Some DataProvider public static void Utilities.Datadriven.main(java.lang.String[]) throws java.io.IOException parameters unresolved: at 0 type class [Ljava.lang.String;
@Lavanya23-design - Please post this on the testng-users@googlegroups.com and include the following:
Baseclass: System.out.println("browser opened successfully");
String location = "C:\\Users\\Lavanya\\Documents\\jars\\geckodriver-v0.26.0-win64\\geckodriver.exe";
System.setProperty("webdriver.gecko.driver", location);
driver = new FirefoxDriver();
Thread.sleep(2000);
Robot rb = new Robot();
rb.mouseMove(630, 420);
rb.delay(1500);
rb.mousePress(InputEvent.BUTTON1_DOWN_MASK);
rb.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
rb.delay(1500);
rb.keyPress(KeyEvent.VK_DOWN);
Thread.sleep(2000);
rb.keyPress(KeyEvent.VK_ENTER);
driver.manage().window().maximize();
driver.get("https://qa.sourcelead.com/login");
driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
Datadriven: @DataProvider(name = "TestData") public static void main(String[] args) throws IOException {
FileInputStream fi = new FileInputStream("C:\\Users\\Lavanya\\workspace\\Learning\\TestData\\datadriven test.xlsx");
wb= new XSSFWorkbook(fi); sheet=wb.getSheet("Sheet1"); try {
for(int i=1; i<=sheet.getLastRowNum(); i++){ String name=sheet.getRow(i).getCell(0).getStringCellValue(); System.out.println(name);
String identity= sheet.getRow(i).getCell(1).getStringCellValue();
System.out.println(identity);
}
}catch(Exception e){
e.getMessage();
}
}
}
Loginpage:
public class LoginPage {
WebDriver driver1;
static By sourceleaduserName = By.xpath("//input[@id='usernameval']");
static By sourceleadpassword = By.xpath("/html/body/div[3]/div[1]/div/form/span[2]/input");
static By submit = By.xpath("/html/body/div[3]/div[1]/div/form/input[7]");
//static By location=By.xpath("//div[@id='locDiv41782']");
public LoginPage(WebDriver driver)
{
this.driver1=driver;
}
public LoginPage() {
public void loginApplication(String username) { driver1.findElement(sourceleaduserName).sendKeys(username); } public void loginuser(String password) { driver1.findElement(sourceleadpassword).sendKeys(password); } public void clickLogin() { driver1.findElement(submit).click(); } public void loginintoSourcelead(String username,String password) { this.loginApplication(username); this.loginuser(password); this.clickLogin();
}
Logintest: public class LoginTest extends Baseclass { public WebDriver driver1;
LoginPage lp= new LoginPage(driver1);
@Test(dataProvider="TestData",dataProviderClass=Datadriven.class)
public void Login(String username,String password)
{
System.out.println("login test case program started");
lp.loginintoSourcelead(username, password);
System.out.println("program executed successfully");
}
}
can u please give me the clarity where did i wrote the wrong code
testNg version:6.11
@Lavanya23-design - Please post your question on the TestNG forums : https://groups.google.com/forum/#!forum/testng-users
Note: The latest released version of TestNG is 7.1.0
. Please use that.
@NavdeepKSidhu - If you need help with anything on TestNG I would suggest that you please post your query on the testng-users google forums.
Hi All, I have written the code to login to LetsKodeIt website and tried to run the code in a node(Selenium GRID) machine by passing the input thru Excel Utility. But this same code is working when i run the code by connecting to a node on the same machine(Hub and Node registered on the same machine)
Can any of you guys please fix the code or help me to fix and execute and produce results.
TestNG Version 6.12 Selenium Standalone Server 3.5.3 ExcelData.xlsx Error Trace.txt
Please find the attached code files and error trace file.
Excel_Grid.xml: