I am having trouble clicking on a link in a webpage using the selenium webdriver in firefox.
Here is a snippet of my code regarding the issue:
WebElement option = driver.findElement(By.id("AccNumSpan" + i));
if(option.getText().contains("48494")){
List <WebElement> listOfOptions1 = driver.findElements(By.xpath("//*[@id='row" + i +"']/td[10]/nobr"));
for(WebElement option1 : listOfOptions1){
System.out.println(option1.getText());
String id = option1.getAttribute("id");
System.out.println(id);
option1.click();
}
Here is the html of the link that I am trying to click:
<td class="cell" align="left">
<nobr>
<span id="link15796367" class="stmtListTableLinkDocument" onclick="billDocsClient.ShowDocTypeList(event, 'table#StatementTable', 'span#link15796367', 908244, 15796367, '6728_22198', '48494 (Merrill Lynch Europe PLC)', '6/1/2014', '34969691/175474');" onmouseout="this.className='stmtListTableLinkDocument'" onmouseover="this.className='docLink'">View Monthly Invoices</span>
</nobr>
</td>
When I run the code, it prints "View Monthly Statement" from option1.getText ( so it does find the element), but when I try option1.click() (which is what I want to do) nothing happens except the text gets underlined or whatever but the link isn't opened. Also, it does not print anything for option1.getAttribute("id") or for any attribute using .getAttribute
Any way to get around this? All help is appreciated, thanks
View Monthly Invoices? Also, can you show more of the html so we can see the element with idAccNumSpan?