can't find controls in page, but only when running via selenium-server
I have a set of tests that I've developed using the Selenium IDE in Firefox. Tests run fine and all pass. Now I'm trying to port those over to C# and run the tests for IE using MSTest and selenium-server. Here's the sequence of events:
- Run all tests on Firefox via Selenium IDE. All tests pass.
- Export tests to MSTest (Nunit export, rename some stuff etc.)
- Start selenium-server-1.0.3
Run the tests in VS2008. Selenium setup is:
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost/theSite/");
; note that I can browse tohttp://localhost/theSite/
just fine.4a. Confirm test is launching Firefox. Got result: 17:00:30.290 INFO - Preparing Firefox profile... 17:00:33.842 INFO - Launching Firefox...
First test ( waitForText "Login" in control "ctl00_TopNavBar_LoginStatus1") fails. Can't find the control.
if ("Login" == selenium.GetText("id=ctl00_TopNavBar_LoginStatus1")) break;
orif ("Login" == selenium.GetText("ctl00_TopNavBar_LoginStatus1")) break;
All other tests fail as well -- same reason. Each test has a
waitForText
at the top.
Tried running the test in *chrome, *iexploreproxy and *firefox. All fail for the same reason.
Tried dumping a screenshot using selenium.CaptureEntirePageScreenshot("c:\\temp\\开发者_运维百科screenshots\\seleniumSite.png", "background=#FFFFFF");
and the screenshot is just a white bar.
So, my question is, how do I go about debugging this and figuring out what the real problem is? Clearly the page will render and the tests will pass. It's just when I try those tests in Selenium-RC that it fails so badly. Does the Selenium IDE have some bugs related to exporting tests to C#? (I have noticed one bug).
Are you executing selenium.Start()
and selenium.Open()
? Do you see the page opened in the browser?
Full initialization should be something similar to:
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost/");
selenium.Start();
selenium.Open("/theSite/");
Important Note! test your IDE tests by starting with an empty page. Also, when using the IDE, if a command only has one parameter put it in the Target field, even if it isn't a control name.
精彩评论