0

アップデート:

2.29欲求不満の部分である非常に矛盾のオンとオフのように更新した後、私は同じ問題を抱えています。

更新終了:

Selenium WebDriver 2.25 バージョン。ブラウザ: FF (17.0.1 バージョン) & IE (8)

私をいらいらさせたり夢中にさせたりする最も1つのことは、古い要素に関するものであり、テストケースを常に実行する方法がわかりません。テストケースが成功することも失敗することもあり、CSSSelectorを使用して要素を見つけていますが、テストケースのオン/オフはまだ失敗しています....

これが私が要素を見つけるために使用しているものです。

ここにC#の私のコードがあります

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

1 に答える 1

0

私は同じ問題を抱えていて、このように解決しました:

a)IWebElementsを操作するために「dowityretry」のようなメソッドを避けてください。この方法では、テストの実行に多くの時間がかかり、不要であり、テストが断続的に失敗するためです。

b)Firefoxバージョンを5にダウングレードします(おそらくFF 3.6から6が正常に機能するまでですが、FFの新しいバージョンは「ハブ/セッションからの応答がありません...」のような断続的な例外をスローします。

c)ページ上のAjaxを介してロードされるテストで要素を処理する必要がある場合は、要素のロードを停止できるjs関数を必ず提供してください。そのため、FindElementの前にWebDdriverからこの関数を呼び出して、必要な操作を行う必要があります。

于 2013-03-14T21:05:36.307 に答える