2012-07-26 23 views
0

我在Firefox中使用硒與C#.NET4.0自動化的過程:硒打開Firefox和停止所有進程

static void Main(string[] args) 
    { 
     selenium = new DefaultSelenium("localhost", 4444, "*firefox", "https://www.microsoft.com/"); 

     selenium.Start(); 
     selenium.SetSpeed("900"); 

     selenium.WindowMaximize(); 
     selenium.WindowFocus(); 

     Login(); 
    } 

public static void LogIn() 
     { 
      verificationErrors = new StringBuilder(); 

     selenium.SetSpeed("900"); 
     selenium.Open("/Login.aspx"); 

     selenium.Type("id=ctl00_cphBody_objLogin_UserName", "user"); 

     selenium.Type("id=ctl00_cphBody_objLogin_Password", "[email protected]"); 

     selenium.Click("id=ctl00_cphBody_objLogin_LoginImageButton"); 

     selenium.WaitForPageToLoad("30000");  

      try 
      { 
       selenium.IsTextPresent("Orders - Drug Testing"); 

      } 
      catch (Exception) 
      { 
       Console.WriteLine("Could't find text: Orders - Drug Testing."); 

      } 


    } 

火狐打開,然後什麼都不會發生的。它不會導航到請求的頁面。

這是它的樣子。我究竟做錯了什麼?一切工作正常IE

enter image description here

回答

2

導航到所請求的頁面,需要使用下面的一段代碼。

硒不瀏覽網頁或基本URL自動直到&除非你調用

selenium.open(" < your url goes here > "); 

例:selenium.open("https://mail.google.com");

+0

非常感謝你的幫助。這是一個很好的觀點,我應該包括我的其他代碼,告訴你我已經做到了。 ive更新了我的問題 – 2012-07-27 13:10:48

+0

yaar你在嗎? – 2012-07-27 21:45:32

+0

你用firefox 5.x或3.6.x的標準版本試用了嗎? – 2012-07-30 04:48:24