1

I am Using Selenium WebDriver and reading Data from a excel sheet that contains

Username and Password but the problem is this sheet contains both numeric Values and String Values due to which its throwing error:

Cannot get a STRING value from a NUMERIC cell

Username: rainrrr , shamz, tabraiz

Password: rainrrr ,123456,123456

Please Help

public void AdminLogin(String UserName, String Password) throws Exception
{

    System.setProperty("webdriver.chrome.driver", "C:\\Users\\amomin\\Desktop\\selinium\\chromedriver.exe");
     driver =new ChromeDriver();
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

    driver.get("My Path");

    driver.findElement(By.xpath(".//*[@id='UserName']")).sendKeys(UserName);

    driver.findElement(By.xpath(".//*[@id='Password']")).sendKeys(Password);

    driver.findElement(By.xpath(".//*[text()='Submit']")).click();

    Thread.sleep(5000);


    Assert.assertTrue(driver.getTitle().contains("Dashboard - RainMaker"),"Login Fail");

    System.out.println("User Login Successfully");

}
public Object[][] LoginData()
{


    libDDT config=new libDDT("C:\\Users\\amomin\\workspace\\DataDrivenTest\\TestData\\TestData.xls");
    int rows=config.getRowCount(0);

    Object[][] data = new Object[rows][2];

    for(int i=0;i<rows;i++)
    {

        data[i][0]=config.getdata(0, i, 0);
        data[i][1]=config.getdata(0, i, 1);

    }

    return data;
}   
2
  • If the string is starting with number, in excel, format data as text by prefixing numeric value with single quotation ('). Ex: 123 as '123 Commented Dec 21, 2016 at 12:16
  • Thanks buddy it worked (Y) Commented Dec 21, 2016 at 12:57

1 Answer 1

1

Try this by saving Numeric values in text format.

If the string is starting with number, in excel, format data as text by prefixing numeric value with single quotation ('). Ex: 123 as '123

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.