C# selenium環境配置

來源:互聯網
上載者:User

標籤:rem   windows   ati   系統變數   官網   void   log   use   rgb   

1.下載C#selenium   selenium官網:  http://www.seleniumhq.org/download/ 下載後解壓:  開啟net35後,將裡面的dll檔案添加到ranorex中;2.瀏覽器環境配置

將需要用到的瀏覽器chrome,firfox,等exe所在的檔案

夾添加到系統變數path中去,必要的時候需要重啟電腦;

這一步很重要,否則運行下面的指令碼開啟不了瀏覽器,需要在指令碼中添加瀏覽器地址 3.本地運行指令碼;using Selenium;using OpenQA.Selenium;using OpenQA.Selenium.Chrome;public void Test001()        {              IWebDriver selenium = new ChromeDriver();              selenium.Navigate().GoToUrl("http://www.baidu.com/");              //selenium.FindElement();        } 4.在遠程機執行remoting遠程機環境配置:
  • 需要將瀏覽器添加到系統變數path中
  • 需要下載selenium-server-standalond.jar
  • 然後再cmd或者windows PowerShell中進入到selenium-server-standalond.jar所在的檔案夾,執行命令,開啟服務,命令如下
  • PS C:\Users\cpr018\Desktop\selenium> java -jar selenium-server-standalone.jar
  • 在用戶端運行指令碼,即可在遠程執行測試指令碼
  • remoting其他詳細設定請看 http://www.cnblogs.com/tanghuang/p/6829258.html
 用戶端指令碼: using Selenium;using OpenQA.Selenium;using OpenQA.Selenium.Chrome;using OpenQA.Selenium.Remote;public static void test001()        {              //uri中的ip為遠程機的ip,開啟服務預設連接埠為4444              var driver = new RemoteWebDriver(new Uri("http://192.168.226.131:4444/wd/hub"), DesiredCapabilities.Chrome());              driver.Navigate().GoToUrl("http://www.baidu.com/");           }   

C# selenium環境配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.