Selenium WebDriver Click issue in Internet Explorer

11,559

You haven't said what browser(s) you're seeing the problem with, but I'm going to use my psychic debugging powers to deduce that you're probably talking about Internet Explorer. There are known challenges with the IE driver.

One set of challenges is that you need to set the zoom level of the browser to 100%, or the IE driver can't calculate the coordinates to click on properly. This is often the case when clicking works on one machine but not another, and is documented in the project wiki.

Another class of problems deals in particular with window focus. One alternative is to only use simulated events for the IE driver. This approach has its own pitfalls, but it may work in your situation. Since you mentioned that you're using C#, here is the code for the .NET bindings to disable native events.

InternetExplorerOptions options = new InternetExplorerOptions();
options.EnableNativeEvents = false;
IWebDriver driver = new InternetExplorerDriver(options);
Share:
11,559
Joe Pitz
Author by

Joe Pitz

Currently working at Qualcomm, writing python scripts, Java and C++, testing embedded systems Like playing around with Electronics, anything technical. Currently working on C/C++ certificate at UCSD

Updated on June 26, 2022

Comments

  • Joe Pitz
    Joe Pitz almost 2 years

    Using Selenium WebDriver on several Windows 7 test workstations.

    FireBug Html of Button is listed below:

    <input type="submit" style="border-color:Black;border-width:1px;border-style:solid;
    font-family:tahoma,arial;font-size:0.7em;" id="UserPassword1_LoginButton" 
    onclick="javascript:WebForm_DoPostBackWithOptions(new  WebForm_PostBackOptions(&quot;UserPassword1$LoginButton&quot;, 
    &quot;&quot;, true, &quot;UserPassword1&quot;, &quot;&quot;, false, false))" value="Log      In" name="UserPassword1$LoginButton">
    

    A snippet of Selenium C# code is below:

    try
            {
                // Click on the button identified by Id
                IWebElement query = Driver.FindElement(By.Id(strControl));
                query.Click();
            }
    

    On some windows test workstations the button click method works just fine. On other Windows 7 test workstations the button click does not press the button, The button is just highlighted.

    I also have seen a similar problem where some times I have to include two:

    query.Click();
    

    commands in a row to get the button to press.

    We have been trying to figure out what is different between environments but are not coming up with any solutions.

    Any ideas on how to troubleshoot this problem or if anyone has a solution to this problem.

    Thanks

    Joe