Selenium / Firefox: Command ".click()" doesn't work with a found element

Finally I found an answer that works with Firefox as well as Google Chrome.

WebElement we = this.driver.findElement(By.id("size-btn"));

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", we);

waitForElementPresent(By.xpath("//div[@id='size-btn' and contains(@class,'opened')]/span"));

Thanks for reading me.


I am not sure why are you using this Xpath, if you have freedom to change Xpath then record the element using selenium IDE and use Xpath::position from drop down list of target(it picks unique path relative to html header), it will solve problem of dynamic locator. And try below mentioned events.

1- Use clickAt.

2- Use fireevent(focus) and then click. Sometime it happens some element in back ground is getting loaded, when it gets loaded, focus move there hence elementNotVisible error.

3- Use mouseDownRight.