This problem started when I switched from testing on the www website to my version of localhost. While working in VS 2012, I will start debugging so that localhost is active, disconnect the process so that I can test it, and then run any test that I like. For a very simple example:
[Test] public void CanGoToHomePage() { Pages.HomePage.Goto(); Assert.IsTrue(Pages.HomePage.IsAt()); }
And the functions that it refers to here:
public class HomePage { const string Url = "http://localhost:3738"; const string HomepageTitle = "FunnelFire - Home Page"; public void Goto() { Browser.Goto(Url); } public bool IsAt() { return Browser.Title == HomepageTitle; } }
And the real selenium code is here:
public static class Browser { static IWebDriver webDriver = new FirefoxDriver(); public static void Goto(string url) { webDriver.Manage().Window.Maximize(); webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); webDriver.Url = url; } }
Now the problem. The 10 second implicit wait that I added in the browser successfully waits no more than 10 seconds after the page loads to find out if it can find any information I want to find, this is not a problem.
As I said, after I switched to testing on the local host, suddenly I had a strange problem when the page starts loading (i.e. the screen is still completely white, nothing is finished), or even sometimes the next page is just barely finished and all of a sudden the test will simply go up and fail, indicating an IsAt confirmation returning false, even if the page that it loaded was correct. I could run this test right away again and it would pass without problems. Run it a third time, and it may accidentally fail again. I'm honestly not sure what causes the problem and any help would be appreciated!
source share