selenium rc + c# how to handle the timed out problem after runned a new browse?

all When I learned the selenium rc how to use selenium.click to open a new browse, I have met a problem. The new browse can be opened correctly, but the test tool NUint showed "timed out" problem, whatever I added the time, it always has the timed out problem.The whole codes as following:

[Test]
    public void SelectTest()
    {
        //selenium = new DefaultSelenium("localhost", 4444, "*chrome","http://www.webkey.cn/demo/docs/index2.asp?url=/demo/docs/menuselect/");
       // selenium.Start();
        selenium.Open("http://www.webkey.cn/demo/docs/index2.asp?url=/demo/docs/menuselect/");
        selenium.WaitForPageToLoad("8000");
        selenium.SelectWindow("name=main");
        selenium.Select("city","label=上海市");
        Assert.AreEqual("上海市",selenium.GetSelectedLabel("city"));

        selenium.Select("country","index=1");
        Assert.AreEqual("徐汇区",selenium.GetSelectedLabel("country"));
        selenium.SelectFrame("relative=up");
        selenium.SelectFrame("Header1");
        selenium.Click("link=首页");
        selenium.WaitForPageToLoad("10000");// This code has timed out problem.
}

Answers


First increase default selenium timeout(as i remeber defaulttimeout = 30000):

selenium.SetTimeout("90000"); // 1.5 minute

And second increase wait time for page load:

 selenium.WaitForPageToLoad("10000"); // it's only 10 seconds, 
 //increase to 60000 - one minute

EDIT:

At that i've tested all clicks done by ajax and i use followoning methiod in order to wait some element on page after redirect, so try to use this for wait redirect:

 public static bool WaitForElement(String waitingElement, DefaultSelenium selenium)
        {
            var isElementExists = selenium.IsElementPresent(waitingElement);
            if (!isElementExists)
            {
                Thread.Sleep(50);
                return WaitForElement(waitingElement, selenium);
            }
            else
            {
                return isElementExists;
            }
        }

Example:

 selenium.Open("/sign-up");
 WaitForElement("//input[@name='Invite']", selenium);//Wait...

Try

selenium.clickAndWait("link=首页");<br>
selenium.WaitForPageToLoad("60000");

Need Your Help

UIViewController - orientation changes don't get reported

uiview uiviewcontroller uidevice

In my UIViewController subclasses, I impliment - (void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation, but it never gets called, although I have

Does PartialView do what I think it should (but doesn't)?

jquery asp.net-mvc ajax

I have a div on an ASP.NET MVC page that I would like to populate dynamically (at user request) using jQuery. I currently have jQuery placing a JSON call to my controller, which returns a JSON obj...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.