Selenium 2.0b3 IE WebDriver, Click not firing

后端 未结 18 1788
我寻月下人不归
我寻月下人不归 2020-11-29 02:33

When using the IE driver with IE9, occasionally the Click method will only select a button, it wont do the action of the Click(). Note this only happens occasionally, so i d

相关标签:
18条回答
  • 2020-11-29 02:51

    Absolutely none of the other things worked for me. Some InternetExplorerDriver click()s were working for me, some weren't. Then I discovered I had missed one line in the documentation: the browser's zoom level must be set to 100%.

    I'm sure all of the other answers refer to cases where the zoom level is at 100% already, but it did fix my case. So do check that first.

    0 讨论(0)
  • 2020-11-29 02:51

    PHPUnit + facebook / php-webdriver sometimes the function click() doesn't check checkbox element.

    my solution is:

    $Element = $WebDriver->findElement(
        WebDriverBy::id('checkbox_id')
    );
    
    if(false === $Element->isSelected())
    {
        $Element->sendKeys(WebDriverKeys::SPACE);
    }
    
    0 讨论(0)
  • 2020-11-29 02:52

    I used, as workaround, SendKeys with an empty string before each Click:

    element.SendKeys("");
    element.Click();
    
    0 讨论(0)
  • 2020-11-29 03:00

    I find the IE driver buggy and the same version of my code behaves differently on different machines with the same version of IE.

    To get consistently before each action I do the following.

       driver.SwitchTo().Window(driver.CurrentWindowHandle);//Force Focus
    

    For me this makes the IE driver behave more as expected.

    0 讨论(0)
  • 2020-11-29 03:02

    Got the same problem, click does not work with my IE. I found a workaround where I do a Driver.FindElement(By.Name("...")).sendKeys("\n") to perform the click (basically I just press enter on the button). Not very clean but it works until the problem is fixed!

    0 讨论(0)
  • 2020-11-29 03:02

    I resolved problem whith .click() next way. I used JS and executeScript(JS, WebElement el) instead of .click().
    Example:

    protected void clickForIE(WebElement element){  
            ((JavascriptExecutor)wd).executeScript("var tmp = arguments[0];
              tmp.click()", element);  
        }
    

    But after using this method we should wait while page loading. And that's why I used next method:

    protected synchronized void pageWaitLoad() {  
            String str = null;
            try {
                str = (String)((JavascriptExecutor)wd).executeScript("return document.readyState");
            }
            catch (Exception e) {
    // it's need when JS isn't worked
                pageWaitLoad();
                return;
            }
            System.out.println("ttt " + str);
            while(!str.equals("complete")){
                try {
                    Thread.currentThread().sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                str = (String)((JavascriptExecutor)wd).executeScript("return document.readyState");
            }
        }
    

    You must call pageWaitLoad() every time after clickForIE().

    0 讨论(0)
提交回复
热议问题