Reputation: 413
So I have an input element on a page and I need to click on it to go to another page. Problem is that when I user click() or submit() on the element nothing happens. I have a custom highlight method that is working so I can see that I am actually on the correct element. The click() just seems to not be working on it for some unknown reason.
Here is the html I'm working with
<TBODY>
<TR style="" class=" STDLISTROW_O" onmouseover=listMouseOver(this); onmouseout=listMouseOut(this); saveBG>
<TD class=STDLISTBTN>
<INPUT style="COLOR: " onmouseover="listBtnMouseOver(this); window.status = this.status_txt;" onmouseout="listBtnMouseOut(this); window.status = '';" onclick=" event.cancelBubble = true; if (this.getAttribute('clicked') == 'false') { document.location.href = 'client$.startup?P_CLIENT_ID=7605677'; this.setAttribute('clicked', 'true'); } " value=ECR type=button status_txt="client$.startup?P_CLIENT_ID=7605677" clicked="false" saveBtnBG saveBtnC></TD>
Here is my Selenium/Java method
public void clickECRButtonWithID(String clientID) {
log.info("Click the ECR button for the row with client id: " + clientID);
WebElement idRow = driver.findElement(By.xpath("//td[contains(text(),'"
+ clientID + "')]/ancestor::tr"));
WebElementExtender.highlightElement(idRow);
WebElement ecrButton = driver.findElement(By.cssSelector("input[value='ECR']"));
WebElementExtender.highlightElement(ecrButton);
ecrButton.click();
}
I have also tried isolating the parent td of the input and clicking on it with no luck. I'm at a loss here.
Upvotes: 4
Views: 18264
Reputation: 32855
First try other browsers like Firefox and Chrome to make sure your code (locator and such) is correct. Then a couple solutions you might want to try on IE.
ecrButton.click(); // dummy click to focus
// or ecrButton.sendKeys("\n"); // also tries to focus
ecrButton.click(); // do your actual click
Actions
class.new Actions(driver).click(ecrButton).perform();
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", ecrButton);
Upvotes: 7
Reputation: 413
Found this question and it contained the answer that worked for me.
((JavascriptExecutor) driver).executeScript("arguments[0].click()", ecrButton);
There seems to be some sort of bug in the IEDriverServer that doesn't allow you to click on some inputs. Using javascript instead seems to work well.
*Much appreciation to @KrishPrabakar
Upvotes: 0