10

Have a suite of web-drivers tests that run in chrome and IE 10, but will not run in IE 11.

The tests fail in IE-11 when clicking a button as the following action (a form popup) does not occur. I cannot repeat this manually and this only seems to happen in IE-11. No exceptions are thrown when finding the button or clicking the button. This is an intermittent error as sometimes the clicking will work and the tests will run.

I can put an explicit wait before the click(s) occur and tests will then run.

The button is always present in the DOM (not added later by javascript).

I have also added a check so that web-driver will not start interacting (clicking) with a page until after all the initial javascript has finished running on the page. This is done by the last piece of javascript setting a flag.

Has anyone had similar issues?

Edit I don't want to have waits in the test code. Just put them in to debug what was not working

5
  • I've found intermittent IE errors are usually page loading (your mileage may vary). If you are using the page object model on the page, can you get the element as an object and verify it before clicking? I've had better success with that than waits.
    – MichaelF
    Aug 20, 2014 at 13:05
  • I am using the Page Object Model and capturing the a WebElement before attempting to click it...
    – Jon Duffy
    Aug 20, 2014 at 13:09
  • Other than the fragility of IE, if you can't find an obvious error turn up logging and see if you get anything. I've always had IE tests fail and pass on rerun, it's one of the most aggravating parts of Automation that tests will sometimes fail for no obvious reason
    – MichaelF
    Aug 20, 2014 at 13:22
  • 2
    I think it might help to read about the differences between IE10 and IE11. msdn.microsoft.com/library/ie/dn384059 This isn't going to be a quick read, but it seems that something in the application is different in the way it is handled between the two and Selenium. You can look up the control usage in IE11 vs. IE10 and see what the differences might be. That's the best path I can think of without using waits...and then you still might end up with a wait as you might not be able to fix the application.
    – mutt
    Aug 20, 2014 at 17:03
  • To the OP, how did you get this working. I am facing a similar problem
    – user39627
    May 20, 2019 at 11:52

8 Answers 8

10

Check this code. It works properly in IE. All you need to set some capabilities.

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);

driver = new InternetExplorerDriver(ieCapabilities);
2
  • It might be the popup blocking feature? May 15, 2015 at 12:30
  • This produces a build error for me, it's expecting a string for the overload. Did this build for anyone else?
    – DEnumber50
    Nov 8, 2016 at 18:33
2

Personally I would put a wait and in the wait try to click and then verify the popup exists, catch the error and try to click and verify again. That way as soon as it's ready it will return and you aren't using a timer. That is good practice anyway to not just wait a specific time, but wait for a particular event to take place and then move on.

c#

WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(time));
    var popupReady = wait.Until(d =>
        {
            try
            {
                 //click the button
                 //interact with Popup
            }
            catch
            {
                return false;
            }
        });
4
  • I see what you mean. Click and see if the popup appears and then if not click again. My worry would then be that it could hide other issues where buttons are not working properly.
    – Jon Duffy
    Aug 21, 2014 at 9:44
  • Yes, you would want to put all that in the wait. Possibly log any "known" issues during that...although don't log every time otherwise your log might grow really long. But you can just add whatever is needed to ensure that all the functionality is accurate in the popup execution part. Then go back to regular testing afterwards. I know this works, but you got to make sure all your ducks are in a row. If your are nervous about some specific stuff and would like guidance please update your question with that new information.
    – mutt
    Aug 21, 2014 at 12:09
  • So just to clarify, are you suggesting that the tests should try to complete and any 'unusual behaviour' like in the question should be recorded. Perhaps this should be another question but, how and when do you decide to spend time on issues like this that are 'logged' vs developing new tests etc?
    – Jon Duffy
    Aug 21, 2014 at 14:58
  • I would ask that as a separate question and provide more specifics to the question. There are tons of variables involved and most will be specific to your test/goals/reports/requirements/etc... In general it is best for a test to do as much as it can do with each run and log/report specific issues as it runs. This will help alot rather than just failing a test for each failure and then having to manually execute to find the problem and fix it.
    – mutt
    Aug 21, 2014 at 15:55
1

For Selenium 3.0.1, I setup as follow and it works for IE 11.

InternetExplorerOptions caps = new InternetExplorerOptions();
caps.IgnoreZoomLevel = true;
caps.EnableNativeEvents = false;
caps.InitialBrowserUrl = "http://localhost";
caps.UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Accept;
caps.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
caps.EnablePersistentHover = true;        
IWebDriver driver = new InternetExplorerDriver(caps);
1

I also had the same problem in clicking the segment under a page then on the elements but could not click. I have a solution that worked for me and hope the below answer will work for you as well. Add the code snippet.

DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);

// Setting attribute nativeEvents to false enable click button in IE
caps.setCapability("nativeEvents",false);
WebDriver driver = new  InternetExplorerDriver(caps);

It will disbale IE browsers native elements. As far as i know ,native elements i.e. disabling java script that usually present on the click events. Try this out and update here if anyody have better suggestions do let me know.

0

You may try to click it with JS,

JavaScriptLibrary.CallEmbeddedSelenium(driver, "triggerMouseEventAt", element, "click", "0,0");

I guess if disabling Native events brakes other parts of the test, doing clicks with js could be the workaround, It did work for me at least

0

Try next steps:

  1. Open Display settings in Windows (right click on desktop, choose Display Settings)

  2. Set option "Change the size of text, apps, and other items" to 100%.

After this steps, Click() method should work.

This solved my problem with Click() method.

0

I tried javascript click and it worked for me. hope it works for you all too:

WebElement we = driver....
((JavascriptExecutor) driver).executeScript("arguments[0].click();",we)

You can use this if you are trying to click on any link or button

-1

One workaround would be to use Selenium with Sikuli for this test. This way you simulate a real mouse click.

http://www.devengineering.com/blog/testing/how-integrate-sikuli-script-selenium-webdriver

Sikuli is a robust and powerful tool to automate and tests user interfaces screenshots. The core of Sikuli Script is written in Java, which means you can use Sikuli Script as a standard JAVA library with Selenium. The link above shows the details on how to do this.

1
  • Can you articulate your answer a bit further so it is tailored specifically to this question. Although the link is relevant, could you include the specific information into the answer itself?
    – ECiurleo
    Dec 19, 2016 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.