I do not understand why this does not work. The web application I am testing has a popup that is created when a button is clicked. This popup contains a table, each of which is interactive. I have tried many implementations of Actions, selecting a table row, etc., but nothing works. The element is visible to Selenium, it simply will not click on it. The error also does not occur.
ADDITIONAL NOTE. I checked the Action method with other elements and it works, so it should be used as a selector or as it sees it. Very strange behavior. I also tested it in Firefox using the Selenium IDE, and weblement.click () will work with the CSS selector with this.
public class ContactDetails {
WebDriver driverInstance;
public ContactDetails(WebDriver driver){
this.driverInstance = driver;
}
public void enterContactDetails(){
By validAddress = By.cssSelector("#customerAddress > tbody > tr:nth-child(1) > td");
if (Helper.checkElementVisible(driverInstance, validAddress)){
WebElement selectAddress = driverInstance.findElement(validAddress);
Actions actions = new Actions(driverInstance);
actions.moveToElement(selectAddress).click().perform();
}
}
}
Helper Class:
public class Helper {
public static void scrollToElementAndClick(WebDriver driver, WebElement webelement){
Actions actions = new Actions(driver);
actions.moveToElement(webelement).click().perform();
}
, , . Actions Helper.scrollToElementAndClick() . , , !
, , HTML popup :
<div class="someDiv" tabindex="-1" role="dialog" aria-labelledby="ui-1"
style="height: auto; width: 600px; top: 175px; left: 364px; display: block;">
<div class="anotherDiv">
<span id="ui-1" class="ui-title"></span>
<button class="ui-title-close" role="button" aria-disabled="false" title="close">
<span>close</span>
</button>
</div>
<div id="validateCustomerAddress" class="ui-content" style="width: auto; min-height: 0px; max height: none; height: 230px;">
<h2 class="aSection" style="color:#666666">Valid Addresses:</h2>
<table id="customerAddress">
<tbody>
<tr>
<td>ZIP CODE: N/A</td>
</tr>
<tr>
<td>2 POPLAR WAY</td>
</tr>
<tr>
<td>KINSEY DRIVE</td>
</tr>
</tbody>
</table>
</div>
</div>