My code is :

for (int z = 0; z < rows.size(); z++) {

rows.get(z).findElement(By.xpath("//*[@class='ng-scope'][" + (z + 1) + "]//*[@placeholder='Stop Name']")).sendKeys(shuttleObj.getStopArea());


And I want to use repository to pass xpath. I want this value multiple times for every rows in a table but if I am taking properties like

for (int z = 0; z < rows.size(); z++) {

rows.get(z).findElement(By.xpath(props.getProperty("path[" + (z + 1) + "]area")).sendKeys(shuttleObj.getStopArea()));


area=//*[@placeholder='Stop Name']

This code is not working. If I am taking total elements like

path=//*[@class='ng-scope'][" + (z + 1) + "]//*[@placeholder='Stop Name']

It can be able to run but in same row. But I want this value in every rows in a table.

  • use this - props.getProperty(path+ "[" +(Z+1)+ "]" + value) – Upkar Singh May 13 at 4:14
  • sorry my bad just replace value by your area variable name. – Upkar Singh May 13 at 9:27
  • i'm not bale to understand that what you want to do, but why are u using " stiil before path variable and after area variable these are your simple variable with string values which you want to use. – Upkar Singh May 13 at 10:20
  • why are you not directly using this - props.getProperty(path+ "[" +(Z+1)+ "]" + area) – Upkar Singh May 13 at 10:20
  • because path and area are not an elements, these are xpath which i am using in my code like e.g path= //*[@class='ng-scope'] and area=//*[@placeholder='Stop Name'] . I am combining these two xpath and using as one xpath in my code like e.g rows.get(z).findElement(By.xpath("//*[@class='ng-scope'][" + (z + 1) + "]//*[@placeholder='Stop Name']")).sendKeys(shuttleObj.getStopArea()); But I have to use this xpath in below code by using props.getProperty. rows.get(z).findElement(By.xpath(props.getProperty("path[" + (z + 1) + "]area")).sendKeys(shuttleObj.getStopArea())); – Samira May 13 at 11:00

Hope this help you-
Your property file-(db.properties)

area=//*[@placeholder='Stop Name']  

Now in your java class-

String pathValue= props.getProperty("path");
String areaValue= props.getProperty("area");

for (int z = 0; z < rows.size(); z++) 
rows.get(z).findElement(By.xpath(pathValue+"[" + (z + 1) + "]"+areaValue)).sendKeys(shuttleObj.getStopArea());


Note:- Here if your variable rows is also from properties file then with same above way use this.

  • Yes, it's working now. Thank you. – Samira May 13 at 11:51
  • Welcome!, please if it's your answer then accept it. – Upkar Singh May 13 at 11:59
  • @Samira it's your different question please post it as a new question so that everyone can help you. – Upkar Singh May 15 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.