SeleniumHQ/selenium

Selenium Click is not working with IE11 in Windows 10

Closed this issue ยท 43 comments

Meta -

OS: Windows 10
Selenium Version:
3.4.0
Browser:
Internet Explorer 11

Hi Team,
I have the below scripts which was working perfectly fine in my laptop with Windows 7 and IE11.

I had to change my laptop with Windows 10 following which the same scripts is not performing Click action on Login.

It neither gives error. It simply moves on to the next line and fails.
I have added the FEATURE_BFCACHE as per the config mentioned but still its not fixing the issue.
I tried with other application urls too but still its not performing the click action.
Can you please check and help me address this issue.

Script:
System.setProperty("webdriver.ie.driver", file.getCanonicalPath()); DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false); webDriver = new InternetExplorerDriver(caps);
webDriver.findElement(By.id("Login")).click();

Test Case is to open the application url and enter username,password and click on Login. Its an intranet

Please provide concise reproducible test case so that we could act on this issue.

OS: Windows 10
Selenium Version:
3.4.0
JDK - 1.8
IEDriverServer 3.4.0.0
Browser:
Internet Explorer 11

Problem :
Selenium Click is not performing click action on submit button in Windows 10 - IE11 browser
Steps to Reproduce :
Open the url
https://www.americanexpress.com/
Execute the below script
System.setProperty("webdriver.ie.driver", file.getCanonicalPath());
DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
webDriver = new InternetExplorerDriver(caps);
webDriver.findElement(By.id("loginLink")).click();

Expected result
Script should click on Login button and page should throw invalid username and password error

Actual Result
Script runs and completes the test with no failure trace or logs in console but it did not perform click action on the button .

Please let me know if you need any more inputs on this issue.
I suspect, we have this issue with Windows 10 and IE11 combination as the same script is working fine in Windows 7 and IE11 combination
Please help to address this issue.
Note : I tried with other applications and observed the same issue with click.

Hi,

I have also come across this issue, generally you need to get around it by setting the desired capabilities correctly.

DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();

ieCapabilities.setCapability("nativeEvents", false);
ieCapabilities.setCapability("unexpectedAlertBehaviour", "accept");
ieCapabilities.setCapability("ignoreProtectedModeSettings", true);
ieCapabilities.setCapability("disable-popup-blocking", true);
ieCapabilities.setCapability("enablePersistentHover", true);
ieCapabilities.setCapability("ignoreZoomSetting", true);

IE generally does everything by coordinates, so what has happened here is Selenium has asked for the element position to click:
webDriver.findElement(By.id("loginLink"))

Which IE then gives it some coordinates of where it thinks the element is, if the capabilities are set incorrectly or if you are using a different screen resolution then 9 times out of 10 it sends the wrong coordinates back the Selenium, so Selenium clicks the coordinates (hence your test doesn't fail and carries on).

Try setting the capabilities above and see if that helps.

We have been having the same kind of problem as the OP using the Ruby bindings and Watir with a Dell Precision 5510 Windows 10 Laptop. By turning requireWindowFocus to true, I can see that the place Selenium is trying to click the link doesn't correspond with where the link is located on the page. Instead it's clicking in an area of the browser that has nothing in it at all. These are the capabilities settings when the error occurs:

    caps = Selenium::WebDriver::Remote::Capabilities.internet_explorer
    caps[:nativeEvents] = true
    caps[:requireWindowFocus] = true  # or it can be set to false, either way
    caps[:javascriptEnabled] = true
    caps[:ensureCleanSession] = true
    caps[:logLevel] = 'DEBUG'

IEDriverServer 32 bit 3.4.0 (even though the machine is 64 bit -- the 64 bit driver is too slow at sending keys and our scripts time out)
IE 11.1007.10586.0

Of interest: If I turn nativeEvents to false, then the selenium does click on the link, but later when I have to enter some data and send the return key (simulating the enter key being clicked, because that's the only way the company internal web form takes the data) then sending the enter key doesn't have the effect of clicking the enter key (ie, nothing happens).

Crazy detail: This particularly happens when running on a Laptop (Windows 10 with a touch screen), or whenever the laptop RDPs into a desktop running the Watir / Selenium scripts. BUT ... if a larger, non-touch screen monitor is connected to the laptop via HDMI the problem goes away (ie, the link gets clicked when nativeEvents is set to true). This holds for RDP to a remote host as well. I can't understand this except to imagine that some kind of screen location calculation is being made; then perhaps the laptop screen driver software is interacting with IEDriverServer in an unexpected way. What's really strange is that using a non-touch screen monitor plugged into the laptop via HDMI port suddenly makes the code work (ie, the link gets clicked), whether local or using RDP. Changing the laptop screen resolution doesn't seem to help anything. What works, every time, is plugging in a bigger monitor to the HDMI port.

One final bit of strangeness: If a laptop with a big monitor does an RDP session to a desktop or server, the code starts to work, and the RDP can be disconnected and the code will continue to work. If a laptop without a big monitor RDPs to a desktop or server, then the code stops working, and on disconnect will continue to NOT work until the laptop with a big monitor RDPs in again. Then the code starts to work, and continues to work.

Sorry if these comments appear confusing -- perhaps crazy -- but the strange relation of the "link not getting clicked" symptom to the laptop and whether or not a monitor is plugged into the laptop might be useful in identifying an area of code in IEDriverServer to be looked at.

I can probably concoct an example on a public website as OP did. Let me know if that would help. Also I'd be willing to debug the IEDriverServer on our systems (making this work is that important). So you can message me direct if that would help.

@skiprhudy I believe some logs would be helpful. For example, if you can get the trace log level for the case when click doesn't work and the case when it works, we can then compare them to see if there is some interesting difference.

To create log, this is the code you can use:

caps = Selenium::WebDriver::Remote::Capabilities.ie(log_level: 'TRACE', log_file: 'ie.log')
driver = Selenium::WebDriver.for(:ie, desired_capabilities: caps)
browser = Watir::Browser.new(driver)

@p0deje I'm working on getting logs but for some reason Selenium is not creating the log file. Judging by Selenium source and your example I'm passing in appropriate args. Will get some eventually here. Also will work on building IEDriverServer.

edit:
The code in webdriver\ie\bridge.rb in initialize(...) looks like is doesn't support :log_file option; it seems to want switches passed in as :driver_opts instead (line 43 to 49 in my selenium version 3.4.0). But I could be wrong. Need to understand code & intent better.

Try doing the verbose syntax.

caps['logLevel'] = 'TRACE'
caps['logFile'] = 'ie.log'
driver = Selenium::WebDriver.for(:ie, desired_capabilities: caps)
browser = Watir::Browser.new(driver)

I'm getting some logs now. Either approach suggested above works to set up the caps but I had to change the code in bridge.rb of 3.4.0 (starting line 43) to make it correctly copy the opts[:desired_capabilities] hash entry into opts[:driver_opts]:

        %i[log_level log_file implementation].each do |method|
          # next unless opts.key? method
          next unless opts[:desired_capabilities][method] 
          WebDriver.logger.warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
        [DEPRECATION] `#{method}` is deprecated. Pass switches using `driver_opts`
          DEPRECATE
          # opts[:driver_opts][method] = opts.delete(method)
          opts[:driver_opts][method] = opts[:desired_capabilities][method]
        end

To me this looks like a bug in the bridge.rb code, since it's incorrectly trying to access hash attributes (the structure that the code expects is not the structure being passed in with initialize). Maybe my calling code is setting up the opts wrong though I haven't ever noticed that being a problem until I wanted to log something to a file.

I will collect some trace data and post it later.

I think I pointed you into a slight wrong direction.

When using IE locally, you can enable logging with this (no need to monkey patch bridge.rb):

driver = Selenium::WebDriver.for(:ie, driver_opts: {log_level: 'TRACE', log_file: 'ie.log'})

When using IE via remote/grid, you should enable logging with capabilities:

caps = Selenium::WebDriver::Remote::Capabilities.ie(log_level: 'TRACE', log_file: 'ie.log')
driver = Selenium::WebDriver.for(:remote, desired_capabilities: caps)

Sorry for the confusion.

Hi,
I've found this issue on Windows 10 & IE11 and for the most part ieCapabilities.setCapability("nativeEvents", false); works but I find that some elements still can't/won't be clicked.
The only workaround I have at the moment is to perform a JavaScript click:
e.g.
if (browser == "IE")
{
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();", element);
}
else
{
element.click();
}

@realfaisalk Here is where I point out that element.click() and using executeScript("arguments[0].click()") are functionally equivalent.

My apologies. There is an additional phrase missing from my comment. It should read as follows:

@realfaisalk Here is where I point out that element.click() and using executeScript("arguments[0].click") are functionally equivalent in IE when native events are turned off.

I apologize for not having proofread my comment thoroughly enough before hitting the post button. Thank you for pointing out my carelessness.

@jimevans - Ah, thanks. I'll have to look into that a bit more. I do know that on some elements I have to use JS click as a normal click event will fire but nothing will happen. I don't know if it's because those elements have JavaScript that needs to be fired or if it's to do with their z-ordering i.e. behind another element.
I also sometimes find that Actions double-click is the only way to click on an element!! -IE only!

Update - Firefox having issues clicking on some links. JavaScript click works fine.
I'll investigate further but am hampered with not being able to get any trace logs using C#:
#3002

I was having this issue. I found that in Windows 10, Display Setting, you can "Change the size of text, apps, and other items:". By setting this for all displays to 100%, it is working.

Thank you its worked for me.

I had the same issue when switched from using Win 7 to Win 10 machine. There couple configurations that might be overlooked:
IE browser zoom % = the zoom should be 100% - Open your IE browser and click on View then select Zoom (100%)
The size of text, apps and other items: Should be 100%. Select Display and move the bar all way to the left.
I haven't used/configured any Capabilities by the way. I am just sharing my case and everyone has their environment and configuration. Wishing you all best of luck

This is documented in wiki now, so I'm going to close this issue.

FYI: I use a Windows 10 VM to run my tests and Remote Desktop into it. This is controlled by System Administrators.
On a Remote Session you are unable to change the display settings, but I have followed the registry "hack" to set it to 96dpi (100%) by following option four from here https://www.tenforums.com/tutorials/5990-change-dpi-scaling-level-displays-windows-10-a.html#option4

Hope this helps anyone else out there....

This was closed, but was anyone able to resolve this? Selenium click is not working in IE 11. I am using selenium 3.10.0. and 32-bit InternetExplorerDriver exe.
Dependencies used are as - desiredCapabilities.setCapability("ignoreProtectedModeSettings", true); desiredCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
desiredCapabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
desiredCapabilities.setCapability("nativeEvents", true);
desiredCapabilities.setCapability("enablePersistentHover", true);

Can someone please help on this.

I was also getting this issue, but found that it could be resolved by adding this to the capabilities
I am using InternetExplorerOptions instead of capabilities, but you should be able to get the gist.

               ```

options.EnableNativeEvents = false;
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Accept;
options.EnablePersistentHover = true;
options.IgnoreZoomLevel = true;
options.AcceptInsecureCertificates = true; // #Bug - SeleniumHQ/selenium-google-code-issue-archive#2381
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.IgnoreZoomLevel = true;
options.EnsureCleanSession = true;

@Baaleos Thanks!!! As you suggested I have used Internet Explorer options to open IE. Still, selenium click is not working.
InternetExplorerOptions options = new InternetExplorerOptions();
options.enablePersistentHovering();
options.ignoreZoomSettings();
options.introduceFlakinessByIgnoringSecurityDomains();
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.ACCEPT);
options.enableNativeEvents();
options.ignoreZoomSettings();
options.destructivelyEnsureCleanSession();

@Baaleos Can you please help me again?

This issue still exists and it was closed. Is there a Selenium Fix in place or under development?

@TimMcGraw13 What issue do you call "this"? We've documented the requirement to set zoom to 100%. Anyone why calls ignoreZoomSettings() is acting at their own risk.

I still experience the issue of the .Click method that comes with Selenium not functioning anymore. We set our zoom to 100%, and it just doesn't click on anything. Which is bizarre because it used to work just fine. Then it just stopped working, nothing updated on our environments and there were no code changes to the environment.

I am still experiencing this issue as well. All settings are 100% but nothing helps. Could you come up with a solution, please?

I have found that the only way to reliably fix it is with explicit waits like Thread.Sleep........which is really bad coding. Webdriver waits are often hit and miss and do not reliably fix the issue

I am wondering why this issue is closed if there are many people that are still experiencing it.
If it's closed means there is a definitive solution for it. Is it the case? if yes please could someone enlighten me?

@salvada This is something which is documented. So people simply need to read the wiki, specifically around the issue originally posted.

Threads like this have gotten out of hand. And often the issue cited at the end isn't the one at the start,

This thread had an issue in Win10, specifically regarding the driver mis-clicking items. To remedy this, fix your Screen Resolution (Specifically the enhancement listed here: https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver/_compare/0cf46848abd86f06876ee6ad0a41ee098c7327a0...74561c47d0300289087a9ea154164ffeb0e9b778)

@luke-hill I have followed what is written there actually before to come here. Reading the recent posts I see that other people did the same without any success, so it seems to be no the solution to this problem. Basically it's just not possible to click on a button. I get back the following exception:

org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: Cannot click on element
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:25:02.294Z'
System info: host: 'PC0166', ip: '10.0.75.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_172'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities {acceptInsecureCerts: false, browserName: internet explorer, browserVersion: 11, javascriptEnabled: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), se:ieOptions: {browserAttachTimeout: 0, elementScrollBehavior: 0, enablePersistentHover: true, ie.browserCommandLineSwitches: , ie.ensureCleanSession: false, ie.fileUploadDialogTimeout: 3000, ie.forceCreateProcessApi: false, ignoreProtectedModeSettings: false, ignoreZoomSetting: false, initialBrowserUrl: http://localhost:8856/, nativeEvents: true, requireWindowFocus: false}, setWindowRect: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}

I'd advise you to open a new issue. With specifics including selenium version, binding, remote/local, full IE / Edge setup and capabilities you pass in.

@salvada

  1. When you write "same issue" be alert, you are hitting a bias. Not everythin that looks same actually is same. Not all click-related issues caused by the same reason.

  2. Moreover, you've caught a different exception. How can you call it "the same"?

  3. And please don't report an issue until you retest it in the latest version, may be it's already fixed. You're on 3.9.1, but the latest version is 3.13 at the moment.

Anyway for who is interested I found a workaround that is sendkeys(keys.ENTER), instead of clicking.

@barancev no where here is posted an exception and the post is related to selenium 3.4.0 so I am testing with a newer version that specified here. I tried also with the latest version and gives me the same result.
My purpose was not be critic, absolutely not, but it was to understand based on what the issue was closed, maybe there are some action to make that are not mentioned here.

@salvada Just open a new issue with a reproduction sample, don't hijack closed issues. If we decide it's is really the same issue we'll mark it as a duplicate.

Thanxs to @Baaleos , solved for me..

       InternetExplorerOptions options = new InternetExplorerOptions();
        options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
        options.IgnoreZoomLevel = true;
        options.UnhandledPromptBehavior = UnhandledPromptBehavior.Accept;
        options.EnablePersistentHover = true;
        options.EnableNativeEvents = false;
        options.EnsureCleanSession = true;    // this cleansession did the trick

Did anyone found the solution for IE click function stuck after click?
Used the capabilities but no use.
however sendkeys(keys.ENTER) works.

OS: Windows 10
Selenium Version:
3.4.0
JDK - 1.8
IEDriverServer 3.4.0.0
Browser:
Internet Explorer 11

Problem :
Selenium Click is not performing click action on submit button in Windows 10 - IE11 browser
Steps to Reproduce :
Open the url
https://www.americanexpress.com/
Execute the below script
System.setProperty("webdriver.ie.driver", file.getCanonicalPath());
DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
webDriver = new InternetExplorerDriver(caps);
webDriver.findElement(By.id("loginLink")).click();

Expected result
Script should click on Login button and page should throw invalid username and password error

Actual Result
Script runs and completes the test with no failure trace or logs in console but it did not perform click action on the button .

Please let me know if you need any more inputs on this issue.
I suspect, we have this issue with Windows 10 and IE11 combination as the same script is working fine in Windows 7 and IE11 combination
Please help to address this issue.
Note : I tried with other applications and observed the same issue with click.

Did you find the solution for the above problem?

I found exact fix and it is following.
While initiating IE browser, use following InternetExplorerOptions

InternetExplorerOptions ieOptions = new InternetExplorerOptions();		
    ieOptions.RequireWindowFocus = true;

IWebDriver wDriver = new InternetExplorerDriver(webDriverPath,ieOptions);		

This will grab focus windows to IE tab and it allows the click.

I was able to fix this problem after banging my head against the wall by adding "elementScrollBehavior": 1, to my config.