Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium WebDriver Click issue in Internet Explorer

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

like image 971
Joe Pitz Avatar asked Aug 27 '12 19:08

Joe Pitz


People also ask

Why click is not working in Selenium?

We can list the most common reasons for click problems as being one of the following: Wrong web element locations. The existence of a web element that obscures the web element that we want to click. The Selenium WebDriver works much faster than the response of the application.

Why is Selenium Automation slow on IE?

This is because the 64 bit IE Driver sever ( IEDriverServer_x64_2. 53.1 ). I switched to IEDriverServer_Win32_2. 53.1 then it worked, it is superfast now!


1 Answers

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);
like image 65
JimEvans Avatar answered Dec 01 '22 13:12

JimEvans