click command in selenium webdriver does not work click command in selenium webdriver does not work selenium selenium

click command in selenium webdriver does not work


If you know for sure that the element is present, you could try this to simulate the click - if .Click() isn't working

driver.findElement(By.name("submit")).sendKeys(Keys.RETURN);

or

driver.findElement(By.name("submit")).sendKeys(Keys.ENTER);


A major thing to watch out for is whether a button is Enabled or not. You can still click them and nothing will fall over and the element is there but it is not ready to be clicked on so just doesnt do anything.

I've been using webdriver and its taken me most of the day to figure this out!

The following method seems to work reliably (in my environment for one button!)

    private void TryClick(By selector)    {        var wait = WaitUpTo(TimeSpan.FromSeconds(10));        var element = wait.Until(ExpectedConditions.ElementIsVisible((selector)));        //really important bit!        WaitUpTo(TimeSpan.FromSeconds(5))            .Until(d => element.Enabled);        element.Click();    }

you use it something like

TryClick(By.XPath("//button[contains(.//*,'Some Text')]"));


WebElement.click() click is found to be not working if the page is zoomed in or out.

I had my page zoomed out to 85%.

If you reset the page zooming in browser using (ctrl + + and ctrl + - ) to 100%, clicks will start working.

Issue was found with chrome version 86.0.4240.111