(java.lang.string) values in Arguments - how to resolve it

21 views
Skip to first unread message

Rashmi Upari

unread,
Feb 14, 2019, 12:08:59 AM2/14/19
to Selenium Users
Hi,
I am using POM for my project
below is the code for the same and attached is the excel being used...and screenshot to error
not sure why arguments are not being passed without (java.lang.string) 

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;

}

}






TestData_SnapMD.xlsx
Screenshot 2019-02-14 at 10.37.55 AM.png

Venu Adhi

unread,
Feb 14, 2019, 12:36:25 AM2/14/19
to Selenium Users
You are trying to return 3 arguments to your class registerAccount(String firstname, String lastname), so it's throwing dataprovider mismatch...

While retrieving data from excel you should check with below code,

for(int col=0;col<=2;) ---> col0, col1, col2 will be returned

Hope this helps

Rashmi Upari

unread,
Feb 14, 2019, 2:19:43 AM2/14/19
to Selenium Users
Thanks Venu, my problem is resolved
Reply all
Reply to author
Forward
0 new messages