テストの作成にSelenium、C#、NUnitを使用していますが、以下のエラーが発生することがあります:-
OpenQA.Selenium.WebDriverException:URLhttр://lоcalhost:7055 /hub / session / 8dd13f5c-7ca6-4aa6-babc-f0ff6d940f0a/elementに対するサーバーからの応答がありません
スタックトレースは次のとおりです。
OpenQA.Selenium.WebDriverException:OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)のurlhttр:// localhost:7055 / Hub / session / 8dd13f5c-7ca6-4aa6-babc-f0ff6d940f0a/elementに対するサーバーからの応答がありませんc:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ HttpCommandExecutor.cs:line 115 at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ HttpCommandExecutor.cs:line 96 at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Execute(Command commandToExecute)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Firefox \ Internal \ ExtensionConnection.cs :OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute、Dictionary`2 parameters)の128行目:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 795 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String Mechanism、String value)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 836 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementById(String id)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 431 OpenQA.Selenium.By。<>c__DisplayClass2.b__0(ISearchContext context)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 102 at OpenQA.Selenium.By.FindElement(ISearchContext context) c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 272 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:289行目OpenQA.Selenium.Remote.RemoteWebDriver.FindElementById(Stringのc:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 836のSelenium.Remote.RemoteWebDriver.FindElement(文字列メカニズム、文字列値) id)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 431 atOpenQA.Selenium.By。<>c__DisplayClass2.b__0(ISearchContext context)in c:\ Projects \ WebDriver \ Trunk \ dotnet \ src \ WebDriver \ By.cs:line 102 at OpenQA.Selenium.By.FindElement(ISearchContext context)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 272 at OpenQA .Selenium.Remote.RemoteWebDriver.FindElement(By)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 289 atOpenQA.Selenium.Remote.RemoteWebDriver.FindElementById(Stringのc:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 836のSelenium.Remote.RemoteWebDriver.FindElement(文字列メカニズム、文字列値) id)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 431 atOpenQA.Selenium.By。<>c__DisplayClass2.b__0(ISearchContext context)in c:\ Projects \ WebDriver \ Trunk \ dotnet \ src \ WebDriver \ By.cs:line 102 at OpenQA.Selenium.By.FindElement(ISearchContext context)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 272 at OpenQA .Selenium.Remote.RemoteWebDriver.FindElement(By)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 289 at\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 836 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementById(String id)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 431 atOpenQA.Selenium.By。<>c__DisplayClass2.b__0(ISearchContext context)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 102atOpenQA。 Selenium.By.FindElement(ISearchContext context)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 272 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:289行目\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 836 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementById(String id)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:line 431 atOpenQA.Selenium.By。<>c__DisplayClass2.b__0(ISearchContext context)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 102atOpenQA。 Selenium.By.FindElement(ISearchContext context)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 272 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:289行目Selenium.By。<>c__DisplayClass2.b__0(ISearchContext context)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 102 at OpenQA.Selenium.By.FindElement(ISearchContext context)in c: \ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 272 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:289行目Selenium.By。<>c__DisplayClass2.b__0(ISearchContext context)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 102 at OpenQA.Selenium.By.FindElement(ISearchContext context)in c: \ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ By.cs:line 272 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)in c:\ Projects \ WebDriver \ trunk \ dotnet \ src \ WebDriver \ Remote \ RemoteWebDriver.cs:289行目
。####。##。#####。#########。#####。ShareServicesTest.CreateShareWidget()
このエラーが表示されるコード:
Driver.SwitchTo().Frame(frameElement);
var wait = new WebDriverWait(parentContextable.Context.Driver, Timeout);
IWebElement element = wait.Until(d => Driver.FindElement(By.TagName(Tags.Body))); // error in this line
このエラーは、Selenium実装コードの次の行でのみスローできることがわかりました。
private static Response CreateResponse(WebRequest request)
{
Response commandResponse = new Response();
HttpWebResponse webResponse = null;
try
{
webResponse = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
webResponse = (HttpWebResponse)ex.Response;
}
if (webResponse == null)
{
throw new WebDriverException("No response from server for url " + request.RequestUri.AbsoluteUri);
}
else
{ ...
たぶん誰かがrequest.GetResponse()がnullを返す理由を知っているのでしょうか、それとも失敗した場合はex.Responseもnullを返すのでしょうか?
(09.09.2012)申し訳ありませんが、すべての情報を提供しなかった可能性があります。私はFireFoxドライバー、Win7、Selenium2.25.1を使用しています。私のテストはたまにしか失敗しません。デバッグモードでのテストは、リリースよりも失敗する頻度が低くなります。
ここで私はこれが起こる考えられる理由を見つけました。そして、私がそのようなコードを書くと:
Driver.SwitchTo().Frame(frameElement);
var wait = new WebDriverWait(parentContextable.Context.Driver, Timeout);
Tread.Sleep(250);
IWebElement element = wait.Until(d => Driver.FindElement(By.TagName(Tags.Body)));
テストは正常に実行されます。しかし、Thread.Sleepは悪い解決策です。たぶん誰かが別の、もう少し良い解決策を見つけることができるでしょう。