Locators
public class locators_registerAccount
{
//WebDriver driver;
public static WebElement reg_link_click(WebDriver driver) throws Throwable
{
Thread.sleep(2000);
WebDriverWait waitLoginPageChrome = new WebDriverWait(driver, 1500);
//waitLoginPageChrome.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//*[@id=\"loginBoxContainer\"]/div/div/div[2]/div[1]/div[2]/a[2]")));
waitLoginPageChrome.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.linkText("Register for an account.")));
WebElement regclick1=driver.findElement(By.linkText("Register for an account."));
return regclick1;
}
public static WebElement reg_FirstName(WebDriver driver)
{
WebDriverWait waitLoginPageChrome = new WebDriverWait(driver, 50);
waitLoginPageChrome.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/div[4]/div/div/div/div[6]/div/div/div[2]/div[4]/div[1]/div/div[1]/div[1]/div[1]/div/span[1]/input")));
WebElement FN = driver.findElement(By.xpath("/html/body/div[4]/div/div/div/div[6]/div/div/div[2]/div[4]/div[1]/div/div[1]/div[1]/div[1]/div/span[1]/input"));
return FN;
}
public static WebElement reg_LastName(WebDriver driver)
{
WebElement LN=driver.findElement(By.xpath("/html/body/div[4]/div/div/div/div[6]/div/div/div[2]/div[4]/div[1]/div/div[1]/div[1]/div[2]/div/span[1]/input"));
return LN;
}
}
Actions
public class actions_registerAccount
{
//static WebDriver driver;
public static void register_click(WebDriver driver) throws Throwable
{
/*Actions actions = new Actions(driver);
actions.moveToElement(locators_registerAccount.reg_link_click(driver));
actions.click();
//actions.sendKeys("SOME DATA");
actions.build().perform();*/
//WebDriverWait waitLoginPageChrome = new WebDriverWait(driver, 50);
//waitLoginPageChrome.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//*[@id=\"loginBoxContainer\"]/div/div/div[2]/div[1]/div[2]/a[2]")));
locators_registerAccount.reg_link_click(driver).click();
}
public static void reg_FN(WebDriver driver, String firstname)
{
locators_registerAccount.reg_FirstName(driver).sendKeys(firstname);
}
public static void reg_LN(WebDriver driver, String lastname)
{
locators_registerAccount.reg_LastName(driver).sendKeys(lastname);
}
}
Excel
public class excel_data
{
public static Object[][] readData() throws Throwable
{
FileInputStream input_file = new FileInputStream("/Users/rashmimohan/Desktop/Selenium_IDE/TestData_SnapMD.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(input_file);
XSSFSheet sheet = workbook.getSheet("Sheet 1");
DataFormatter dataformat = new DataFormatter();
Object[][] data = new Object[1][3];
for(int row =0; row<1;row++)
{
for(int col=0;col<=2;)
{
System.out.println("COL FOR LOOP " +(row+2) +" " +(col));
data[row][col] = dataformat.formatCellValue(sheet.getRow(row+2).getCell(col));
System.out.println(data[row][col]);
col++;
}
}
return data;
}
}
Main
public class main_registerAccount
{
static WebDriver driver ;
public String patientURL="https://rashmi.qa1.snapvcm.com/public/#/patient";
@Test
public void browseropen() throws Throwable
{
System.setProperty("webdriver.gecko.driver", "/Users/rashmimohan/Desktop/Selenium_IDE/geckodriver");
driver=new FirefoxDriver();
driver.get(patientURL);
// driver.manage().window().maximize();
Thread.sleep(1000);
}
@Test(dataProvider="getdata")
public void registerAccount(String firstname, String lastname) throws Throwable
{
Thread.sleep(1000);
actions_registerAccount.register_click(driver);
actions_registerAccount.reg_FN(driver,firstname);
actions_registerAccount.reg_LN(driver,lastname);
}
@DataProvider
public Object[][] getdata() throws Throwable
{
Object[][] data = excel_data.readData();
return data;
}
}