代码改变世界

Selenium testing Iframe

2009-09-10 17:21  敏捷的水  阅读(2277)  评论(0编辑  收藏  举报
[TestFixture]
public class Search : SeleniumBase
{
  [Test]
  public void Search()
  {
      try
      {
          string path = "Search";
         CaptureScreen(path, "HomePage.jpg");
         selenium.Click("link=MAP SEARCH");
         selenium.WaitForFrameToLoad(SeleniumConfig.GetHostURL + @"/Search", "100000");

         //select iframe
         selenium.SelectFrame("//iframe[@src='/Search']");
         CaptureScreen(path, "Map.jpg");

         selenium.Type("id=key", "London");
         selenium.Click("id=searchPoint");
         Thread.Sleep(5000);

         //back to main window
         selenium.SelectWindow("null");
         Thread.Sleep(5000);
     }
     catch (Exception ex)
     {
         verificationErrors.Append(ex.Message);
         throw ex;
     }
 }