Pregunta

Im working on designing the Data Driven Framework.

Can anyone tell me I'm going in the right way ??

What i done so far,

Getting the Test data from the excel and passing the Test scripts.

Sample Script:

// Getting the test data from the Excel by passing the Test case id and the column header of the Excel.

String username =readexcel("TC001", "Username");
String password =readexcel("TC001", "Password");

driver.findElement(By.Xapth("//div[@username]").sendKeys(username) ;
driver.findElement(By.Xapth("//div[@password]").sendKeys(password) ;

If my application has "20" fields, then i need to call excel for "20 times".

My doubts are

  1. Im going in the right way ?

  2. If not, then im getting all the value from excel for the particular Test case id. How to map with the column header (username, password, first name, lastname, age, address) to the particular field.

  3. If the fields are dynamic like today its 6 fields, tomorrow its 8 fields like (username, password, first name, lastname, age, address, city, pincode) how to map it.

Thanks in Advance.

¿Fue útil?

Solución

You can use Hash Map for this.

Create a class that first reads the headers(i.e username, password etc...) then the data, and map them together.

public HashMap<String, String> variables = new HashMap<String, String>();
variables.put("Username", "//div[@username]");
variables.put("Password", "//div[@password]");

You can add as many elements as you want to a hash map.

Take a look at apache-poi for reading data from Excel and parsing it to the Hash map.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top