java - Selenium webdriver: How can I click these links? -


<a onclick="requestreportgeneration('857f23e1baa767622a91f970963d8918', 'reportdiv31','csv')" href="javascript:void[0];">csv</a> <a onclick="requestreportgeneration('64107e36323e5877c986edc98a17b6e8', 'reportdiv32','csv')" href="javascript:void[0];">csv</a> <a onclick="requestreportgeneration('2cad4d4e5c8855c47a88b6ddf8345735', 'reportdiv33','csv')" href="javascript:void[0];">csv</a> 

i have these 3 links on page , want click each 1 in turn. reading links on page list of webelements , go through each 1 in turn if href contains javascript:void[0] try click it:

for (int = 0; < alllinks.size(); i++) {     string reportlink = alllinks.get(i).getattribute("href");      if (reportlink.contains("javascript:void[0];"))      {         alllinks.get(i).click();         /// more stuff     } 

the problem keep getting error saying element not visible. have tried loading page , instead of getting links doing

driver.findelement(by.xpath("//a[contains(@href,\"javascript:void[0]\")]")).click(); 

but gives element not visible error. can tell me why isn't working?

try putting breakpoint before while loop, debug script, step , use eclipse's display tab interrogate links. try evaluating sample statements like:

alllinks.size(); alllinks.get(i).isdisplayed(); alllinks.get(i).isenabled(); 

there must odd links (or way webdriver seeing them), debugging let find out is.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -