I am trying to Pull date format MM/DD/YYYY from Microsoft Excel 97-2003 Worksheet and populate in the web field cause switch month and day to each other place and that cause script failure.
I want to populate date in the MM/DD/YYYY format(American Format) in the web field. However, in the web field date populate as DD/MM/YYYY.
Following date format I have in my excel sheet:
10/18/1976
When date populate in the web field then it populate as below:
18/10/1976
Following are my code:
package com.Test
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import jxl.Sheet;
import jxl.Workbook;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
import org.testng.annotations.Test;
public class TC20042 extends BaseClass{
@Test
public void registration() throws Exception, InterruptedException {
FileInputStream fi=new FileInputStream("C:\\File\\Book2.xls");
Workbook w=Workbook.getWorkbook(fi);
Sheet s=w.getSheet(2);
try
{
for (int i = 0; i < s.getRows(); i++)
{
//Read data from excel sheet
String s7 = s.getCell(6,i).getContents();
driver.findElement(By.xpath("//*[@id='__o3id9']")).sendKeys(s7);
Thread.sleep(500);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}