標籤: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環境配置