Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium webdriver 服务器没有对url的响应-Selenium WebDriver(C#)_Selenium Webdriver - Fatal编程技术网

Selenium webdriver 服务器没有对url的响应-Selenium WebDriver(C#)

Selenium webdriver 服务器没有对url的响应-Selenium WebDriver(C#),selenium-webdriver,Selenium Webdriver,更新: 更新到2.29后,我也遇到了同样的问题,就像它时断时续的不一致性一样,这是令人沮丧的部分 更新结束: Selenium WebDriver 2.25版本。 浏览器:FF(17.0.1版)和IE(8版) 最让我恼火/让我发疯的一件事是陈旧的元素,我仍然不确定我的测试用例怎么能一直运行并通过;有时我的测试用例通过,有时失败,我使用CSSSelector查找元素,但仍然打开/关闭我的测试用例失败 下面是我用来查找元素的内容 这是我的C代码# 我遇到了同样的问题,并用这种方式解决: a) 避免使

更新:

更新到
2.29
后,我也遇到了同样的问题,就像它时断时续的不一致性一样,这是令人沮丧的部分

更新结束:

Selenium WebDriver 2.25版本。 浏览器:FF(17.0.1版)和IE(8版)

最让我恼火/让我发疯的一件事是陈旧的元素,我仍然不确定我的测试用例怎么能一直运行并通过;有时我的测试用例通过,有时失败,我使用CSSSelector查找元素,但仍然打开/关闭我的测试用例失败

下面是我用来查找元素的内容

这是我的C代码#


我遇到了同样的问题,并用这种方式解决:

a) 避免使用诸如“do wity retry”之类的方法来操作iWebElement,因为这样一来,测试需要花费很多时间来运行,是不必要的,而且测试会间歇性失败

b) 将Firefox版本降级为5(可能从FF3.6降到6,但FF的新版本会引发间歇性异常,如“集线器/会话无响应…”


c) 如果您需要在测试中处理通过Ajax在页面上加载的元素,请确保提供一个可以停止元素加载的js函数,因此,您应该在FindElement之前从WebDdriver调用此函数,然后执行您想要的操作。

提及您在哪个浏览器中遇到此错误,并提供详细信息。为什么要运行旧版本的Selenium?IE&FF的哪个版本?FF(17.0.1版)和IE(8)不,它不是,它是
v2.29.1
:…考虑到FF 17支持直到
v2.27
才出现,我想说是的,至少升级您的Selenium版本,然后重试。这包括绑定和IE驱动程序,自
v2.25以来它有了一些改进。不要使用主网站,我给你的上面链接是到源代码库的直接链接-它是最新的,而网站不是。不,最新的.NET版本是
2.29.1
。如果您可以发布两个问题的完全相同的答案,则表明这些问题是重复的。不要发布第二个答案,你应该标记(或投票)作为重复答案结束。
public class WebDriverUtil
{
       public static IWebDriver driver = StartBrowser();
       private static FirefoxProfile _ffp;
       private static IWebDriver _driver;

        private static IWebDriver StartBrowser()
        { 
            switch (Common.BrowserSelected)
            {
                case "ff":
                    _ffp = new FirefoxProfile();
                    _ffp.AcceptUntrustedCertificates = true;
                    _driver = new FirefoxDriver(_ffp);
                    break;
                case "ie":                    
                    var options = new InternetExplorerOptions();
                    options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                    _driver = new InternetExplorerDriver(options);
                    _driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(2));
                    break;
                case "chrome":
                    //_driver = new ChromeDriver();
                    break;
            } 
            return _driver;
        }    

        public static IWebElement WaitForElement(By by)
        {
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
            return wait.Until(drv => drv.FindElement(by));
        }
}


public class TestCaseEmployee: WebDriverUtil
{
   public static bool EmployeeCase()
   {
      //....
      WaitForElement(By.LinkText("Select All Employee")).Click(); //<<< see error below
   }
}
Test 'M:TestCases.TestCaseEmployee' failed: No response from server for url http://localhost:7056/hub/session/79b742cf-e1dc-4016-bdbb-c2de93cd8fa4/element
    OpenQA.Selenium.WebDriverException: No response from server for url http://localhost:7056/hub/session/79b742cf-e1dc-4016-bdbb-c2de93cd8fa4/element
    at OpenQA.Selenium.Support.UI.DefaultWait`1.PropagateExceptionIfNotIgnored(Exception e)
    at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)