TAGS :Viewed: 5 - Published at: a few seconds ago

[ IE 11 clicks on a button and waits until time out selenium webdriver ]

I have a scenario, where I click a button and a pop up appears, where I need to click another button. Driver is clicking on the button in the page, and with stay's on the same element until timedout. I can see that the button in the pop up is selected but not clicked. I tries using CSS selector instead of XPath. Tried using SendKeys("\n"), Sendkeys(keys.ENTER). Nothing worked.

I'm using IE11, selenium webdriver 2.52, windows 8.1.

Method where driver waits:

public static void ImportThisFile()
    {
        try
        {
            new WebDriverWait(Drivers._driverInstance, TimeSpan.FromSeconds(2000));
            Drivers._driverInstance.FindElement(By.CssSelector("#import-this-file-button")).Click();
            Drivers._driverInstance.SwitchTo();
            new WebDriverWait(Drivers._driverInstance, TimeSpan.FromSeconds(2000));
            Drivers._driverInstance.FindElement(By.CssSelector(".btn.medium.left")).SendKeys(OpenQA.Selenium.Keys.Enter);   //Drivers._driverInstance.FindElement(By.XPath(".//*[@id='process-file-form']/fieldset/div[3]/input"));
            Drivers._driverInstance.SwitchTo().ParentFrame();
        }
        catch(Exception e)
        {
            Drivers._driverInstance.FindElement(By.XPath("html/body/div[6]/div[1]/button")).Click(); ;
            throw new Exception("Import pop up window: " + e);
        }
    }

In the stack trace i'm getting timedout messsage:

Test method SDTestAutomation.SDDirectPage_Tests.Upload_DuplicateData threw exception: 
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:56598/session/c627ffbd-21cf-47c2-abd8-6f7aa10516f5/element timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out
TestCleanup method SDTestAutomation.SDDirectPage_Tests.QuitBrowser threw exception. System.Exception: System.Exception: Logout button is not clickedOpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:56598/session/c627ffbd-21cf-47c2-abd8-6f7aa10516f5/element timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByLinkText(String linkText)
at OpenQA.Selenium.By.<>c__DisplayClass6.<LinkText>b__4(ISearchContext context)
at OpenQA.Selenium.By.FindElement(ISearchContext context)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
at OpenQA.Selenium.Support.UI.ExpectedConditions.<>c__DisplayClass3b.<ElementToBeClickable>b__3a(IWebDriver driver)
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
at SmartDebitTestFramework.HomePage.get_Logout() in 
Result StackTrace:  
at System.Net.HttpWebRequest.GetResponse()
 at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
 --- End of inner exception stack trace ---
  at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
  at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
  at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
  at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
  at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
  at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath)
  at OpenQA.Selenium.By.<>c__DisplayClasse.<XPath>b__c(ISearchContext context)
  at OpenQA.Selenium.By.FindElement(ISearchContext context)
  at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
  at SmartDebitTestFramework.SDDirectPage.ImportThisFile() in 

I have all the basic settings for IE set. I'm using IE 32 bit as 64 bit is very very slow. Can I have any suggestions to get out of this issue? Didn't find a workable solution for me Online.

InternetExplorerOptions options = new InternetExplorerOptions();
options.AddAdditionalCapability("IgnoreZoomLevel", true);
options.AddAdditionalCapability("EnableNativeEvents", false);
options.AddAdditionalCapability("UnexpectedAlertBehavior", "accept");
options.AddAdditionalCapability("EnablePersistentHover", true);          
options.AddAdditionalCapability("IntroduceInstabilityByIgnoringProtectedModeSettings", true);
options.AddAdditionalCapability("RequireWindowFocus", true);
//var options = new InternetExplorerOptions { EnableNativeEvents = false };
// options.AddAdditionalCapability("disable-popup-blocking", true);
_driverInstance = new InternetExplorerDriver(path, options);
// _driverInstance = new InternetExplorerDriver(path);
_driverInstance.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromTicks(500));

Answer 1


If you want to click the element Sendkeys sends keystrokes not mouse clicks. There is an attribute on a popup form called 'acceptbutton' on which you can set to a button name and that button will be clicked when 'enter' is pressed. Another attribute you might want to check is 'Enabled' on the button itself. This is for visual studio forms applications. I dont know what your doing with this driver stuff.