I got stuck for the below code.it has an edit icon for which code are follows:

<a href="#tradeModal" id="tradeModalEdit" data-toggle="modal" class="pull-right" style="margin-left: 12px;" title="Edit trade" onclick="return populateTradeTicketSectionEdit(); ClearTradeModal();"><i class="icon-edit"></i></a>

This is the one for which i coded in selenium :

driver.findElement(By.xpath("//a[@href='#tradeModal'and contains(@id,'tradeModalEdit')]/i[@class='icon-edit']")).click();

when i click on save by using below code:

WebElement saveEditTrade = driver.findElement(By.xpath("//a[@href='#' and contains(@onclick,'return SaveTradeDetails();')]")); //code for saving the details in edit trade pop up//

this works fine but point is when i am clicking on consecutive window edit icon like below:

<a href="#feeModal" data-toggle="modal" class="pull-right" style="margin-left: 12px;" title="Edit fee" onclick="  return clearFeeModal();"><i class="icon-edit"></i></a>

selenium code:

driver.findElement(By.xpath("//a[@href='#feeModal'and contains(@onclick,'clearFeeModal();')]/i[@class='icon-edit']")).click();//code for saving the details in Edit Fee pop up

it has other input fields dats okies but my point is execution fails bcuz its showing element is not visible for last edit code that i posted just above line.i can see when data are populating for saving for 1st code at the same time 2nd edit code pops up eventhough i put implicit wait commands or i tried with expected conditions wait.

Please advise.

  • Did you try using xcode only for the <i> or the <a> rather than nested xcode? Try one element at a time and see if it works! Oct 11, 2014 at 11:25

1 Answer 1


Why didn't you code your locator like this?


Seems like it would have still worked and would have been simpler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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