Hi I'm having trouble clicking on some elements when I'm writing my automation tests. Frustrating as it seems to work when I step through the code but not when I let it just run through in debug. I'm fairly new to selenium so any advice is welcomed.
This is the grid/table I'm looking at. Grid
And this is the HTML for the table body.
<tbody>
<tr data-id="471892">
<td class="checkbox"><span class="checkbox" data-id="471892"></span></td>
<td class="left" data-edit="false"><a href="/Contacts/Contact/471892">Contact1, Test</a></td>
<td class="left" data-edit="false"><a href="/Contacts/Account/258144">Dan Test 1</a></td>
<td class="left" data-edit="true" data-editid="280122">Automation Tester</td>
<td class="left" data-edit="true"></td>
<td class="left" data-edit="true">1234567890</td>
<td class="left" data-edit="true">07123456789</td>
<td class="left" data-edit="true" data-fieldid="324" data-dataid="64345" data-filtertype="10">Sherratt, Rachel
<a class="icon edit" id="grid-edit" style="display: none;"></a>
</td>
</tr>
</tbody>
Trouble is, the developers have added an edit icon for each cell that moves based on which cell you hover the mouse over. So the element isn't always present & no matter what I try it doesn't seem to work.
This is the method I have.
public void gridEditText(IJavaScriptExecutor jse, string text, int cell) {
WebDriverWait wait = new WebDriverWait(Browser.getDriver, new TimeSpan(0, 0, 15));
IWebElement clickableElement = wait.Until(Browser.ElementIsClickable(By.XPath("//*[@id='grid-main']/tbody/tr[1]/td[" + cell + "]")));
jse.ExecuteScript("arguments[0].scrollIntoView()", clickableElement);
clickableElement.Click();
//Grid Edit only appears when the mouse hovers over the cell
IWebElement elem = wait.Until(Browser.ElementIsClickable(By.XPath("//*[@id='grid-main']/tbody/tr[1]/td[" + cell + "]/a[@id='grid-edit']")));
String js = "arguments[0].style.display='inline';";
jse.ExecuteScript(js, elem);
elem.Click();
IWebElement gridEditText = wait.Until(Browser.ElementIsClickable(By.XPath("//*[@id='grid-main']/tbody/tr[1]/td[" + cell + "]/input[@id='grid-edit-text']")));
gridEditText.Clear();
IWebElement gridEditText2 = wait.Until(Browser.ElementIsClickable(By.XPath("//*[@id='grid-main']/tbody/tr[1]/td[" + cell + "]/input[@id='grid-edit-text']")));
gridEditText2.SendKeys(text);
}
Any ideas please? This is one error
An exception of type 'System.InvalidOperationException' occurred in WebDriver.dll but was not handled in user code
Additional information: unknown error: Element <a class="icon edit" id="grid-edit" style="display: inline;"></a> is not clickable at point (1096, 296). Other element would receive the click:" <div class="overlay"></div>
<div class="overlay"></div>that's preventing webdriver from clicking the target element. Find that overlay and make sure it's closed/dismissed. - orde