java - Parameterize the Loop in selenium Webdriver -


how parametrize following code each time new value has take how pass value.

   for(int i=1 ; i<6; i++ )      { greeting[i] = driver.findelement(by.xpath("//table[@width=\"270\"]/tbody/tr[i]/td")).gettext(); system.out.println(""+greeting[i]);  } 

i want each time

greeting[1] = driver.findelement(by.xpath("//table[@width=\"270\"]/tbody/tr[1]/td")).gettext(); system.out.println(""+greeting[1]); 

like on,

please guide me

you have use string's format method this. define variable like

string xpath = "//table[@width=\"270\"]/tbody/tr[%s]/td"; template before loop in loop use

string xpathofelement = string.format(xpath, string.valueof(i)); 

however ideally have wait elements before getting properties.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -