selenium web driver element click not working in windows 10

后端 未结 3 1604
你的背包
你的背包 2021-01-27 02:33

I am using selenium webdriver for automation tool creation in C#. That automation working fine windows 7, but not working windows 10.

ex.

driver.FindElem         


        
相关标签:
3条回答
  • 2021-01-27 02:47

    i got same error when FireFox updated to 47.0.1 version, because WebDriver was not compatible with that version without additional libraries or WebDriver update. Try to update Selenium, new 3.0.0 beta update came out 2016-08-04 at http://www.seleniumhq.org/download/

    0 讨论(0)
  • 2021-01-27 02:57

    Try this:

    Instead of .Click();* use .SendKeys(Keys.Return);

    driver.FindElement(By.XPath("//button[@type='submit']")).SendKeys(Keys.Return);
    
    0 讨论(0)
  • 2021-01-27 03:00

    Update your browsers and drivers, make sure the browsers and driver version match - you can't use driver version 80 on browser version 70, that is why you get TimeoutException

    That being said,

    There are many reasons why click might not work, some of them:

    1. Element is not intractable.
    2. Other element will receive the click.
    3. For some driver implementations, a bug on some end cases.
    4. Rare - no apparent reason.

    First, try the obvious one (submit, not click)

    driver.FindElement(By.XPath("//button[@type='submit']")).Submit();
    

    If the above didn't work, continue here.

    In order to bypass all the Click() logic, use JavaScript to perform a raw click.

    var element = driver.FindElement(By.XPath("//button[@type='submit']"));
    ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();", element);
    

    As an extension method

    public static void JavaScriptClick(this IWebElement element)
    {
        // get the driver
        var driver = (IJavaScriptExecutor)((IWrapsDriver)element).WrappedDriver;
    
        // execute the click
        driver.ExecuteScript("arguments[0].click();", element);
    }
    
    // usage
    driver.FindElement(By.XPath("//button[@type='submit']")).JavaScriptClick();
    

    Resources

    You can check Selenium Extensions (open source) for more samples under folder: /src/csharp/Gravity.Core/Gravity.Core/Extensions

    https://github.com/gravity-api/gravity-core

    https://www.nuget.org/packages/Gravity.Core

    If you use C# you can install the package and use it's extensions directly.

    https://www.nuget.org/packages/Gravity.Core/

    Install-Package Gravity.Core
    
    0 讨论(0)
提交回复
热议问题