Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

c# - Selenium error: No response from server for url http://localhost:7055

I'm using Selenium, C#, NUnit to write tests, sometimes I getting below error:-

OpenQA.Selenium.WebDriverException : No response from server for url httр://lоcalhost:7055/hub/session/8dd13f5c-7ca6-4aa6-babc-f0ff6d940f0a/element

Here is stack trace:

OpenQA.Selenium.WebDriverException : No response from server for url httр://localhost:7055/hub/session/8dd13f5c-7ca6-4aa6-babc-f0ff6d940f0a/element at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request) in c:ProjectsWebDriverrunkdotnetsrcWebDriverRemoteHttpCommandExecutor.cs:line 115 at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) in c:ProjectsWebDriverrunkdotnetsrcWebDriverRemoteHttpCommandExecutor.cs:line 96 at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Execute(Command commandToExecute) in c:ProjectsWebDriverrunkdotnetsrcWebDriverFirefoxInternalExtensionConnection.cs:line 128 at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in c:ProjectsWebDriverrunkdotnetsrcWebDriverRemoteRemoteWebDriver.cs:line 795 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value) in c:ProjectsWebDriverrunkdotnetsrcWebDriverRemoteRemoteWebDriver.cs:line 836 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementById(String id) in c:ProjectsWebDriverrunkdotnetsrcWebDriverRemoteRemoteWebDriver.cs:line 431 at OpenQA.Selenium.By.<>c__DisplayClass2.b__0(ISearchContext context) in c:ProjectsWebDriverrunkdotnetsrcWebDriverBy.cs:line 102 at OpenQA.Selenium.By.FindElement(ISearchContext context) in c:ProjectsWebDriverrunkdotnetsrcWebDriverBy.cs:line 272 at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by) in c:ProjectsWebDriverrunkdotnetsrcWebDriverRemoteRemoteWebDriver.cs:line 289 at

.####.##.#####.#########.#####.ShareServicesTest.CreateShareWidget()

Code where this error appears:

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

I figured out that this error can be thrown only in this lines of Selenium implementation code:

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
            { ...

Maybe someone knows why request.GetResponse() returns null, or if it fails why ex.Response also null?

(09.09.2012) Sorry but maybe I didn't provide all information. I'm using FireFox driver, Win7, Selenium 2.25.1. My test fails only sometimes. Test in debug mode fails less often then in Release.

Here I found possible reasons why this happen. And if I write such code:

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

Test runs OK. But Thread.Sleep is bad solution. Maybe somebody could find another, little bit better solution.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...