差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
rf:rf:remoteselenium [2015/11/27 22:10]
tony
rf:rf:remoteselenium [2023/06/25 09:48] (目前版本)
行 1: 行 1:
-{{tag>​RobotFramework}}+{{tag>​RobotFramework ​Selenium}}
 ====== Remote Selenium - 透過另外一台電腦的瀏覽器做測試 ====== ====== Remote Selenium - 透過另外一台電腦的瀏覽器做測試 ======
 ===== Problem ===== ===== Problem =====
行 5: 行 5:
 ===== How to? ===== ===== How to? =====
 我們所要測試的瀏覽器,主要是IE與Firefox。而在Selenium2中,都是透過Web Driver的方式去執行瀏覽器動作。而我預想的測試模式,如下圖所示:​\\ 我們所要測試的瀏覽器,主要是IE與Firefox。而在Selenium2中,都是透過Web Driver的方式去執行瀏覽器動作。而我預想的測試模式,如下圖所示:​\\
-{{:​rf:​rf:​rf_remote_selenium_arch.png?​500|}}+{{:​rf:​rf:​rf_remote_selenium_arch.png|}}\\ 
 +Test Host負責透過Robotframework執行我們的測試工作,而與Web相關的則是透過Selenium2Library。Selenium2Library會透過Remote Selenium模式,請遠端的Selenium Server,根據請求的瀏覽器,去透過對應的Web Driver,喚起對應的瀏覽器做測試。接下來告訴大家該如何實現:​ 
 +==== Prepare ==== 
 +在Remote的Server上,請先安裝好你想測試的瀏覽器。接著到此[[http://​www.seleniumhq.org/​download/​|link]]下載對應的web driver,與Selenium Standalone Server。我使用的Selenium Server是2.48.2版本,相依於Java7以上。以下是我安裝清單:​ 
 +  * Java,7 & 8。 
 +  * Selenium Standalone Server,v2.48.2。 
 +  * Google Chrome Driver,v2.20。 
 +  * The Internet Explorer Driver Server,v2.48.0,32 bit。使用64bit會有輸入過慢問題,可參考此[[https://​code.google.com/​p/​selenium/​issues/​detail?id=5116|issue]] 
 +{{:​rf:​rf:​rf_remote_selenium_folder.png|}} 
 +==== Remote Server Setting ==== 
 +  * 請先設好防火牆,預設的Selenium Standalone Server使用4444/​tcp;IE Driver Server: 5555/​tcp;Google Chrome Driver: 9515/​tcp。最簡單就是全執行一次,就會跳出防火牆設定請你處理了。 
 +  * 新增執行Selenium Server的腳本:<​code bash> 
 +@echo off 
 +set BASE=%~dp0 
 +set JAVA_PATH=%BASE%jre7\bin\java.exe 
 +set PATH=%PATH%;​%BASE%;​ 
 + 
 +cd /d "​%BASE%"​ 
 +"​%JAVA_PATH%"​ -jar selenium-server-standalone-2.48.2.jar 
 +</​code>​ 
 +腳本請預先執行,也可以直接丟到系統啟動中。 
 +==== Robot Test Cases ==== 
 +調整原本的Robot Test Cases其實也不難,只要多增加一個remote_url參數即可:​ 
 +<​code>​ 
 +remote_url=http://​${selenium_server_ip}:​4444/​wd/​hub 
 +</​code>​ 
 +<code html> 
 +<​tr>​ 
 +<td class="​name"><​a name="​test_Test Selenium2"></​a></​td>​ 
 +<​td>​open browser</​td>​ 
 +<​td><​a href="​http://​google.com">​http://​google.com</​a></​td>​ 
 +<​td>​googlechrome</​td>​ 
 +<​td>​remote_url=http://​192.168.1.150:​4444/​wd/​hub</​td>​ 
 +</​tr>​ 
 +</​code>​ 
 +==== Demo ==== 
 +請參考[[https://​youtu.be/​Ifq93Pbs8SE|link]]。\\ 
 +我執行一個測試用的測試案例,主要用來確認在IE、Firefox與Google Chrome的Remote Selenium情況下,抓圖功能是否正常。 
 +===== Others ===== 
 +如果在測試IE 11時,有遇到啟動瀏覽器卻無法做任何操作情形,可以看看Reference 3。必須透過修改註冊檔去解決這問題,也可以直接使用我提供的registry去修改:​ {{:​rf:​rf:​iedriverserver_x64.zip|link}}(only for x64 OS)。 
 +===== Reference ===== 
 +  - [[https://​code.google.com/​p/​selenium/​wiki/​InternetExplorerDriver|InternetExplorerDriver]] 
 +  - [[https://​code.google.com/​p/​selenium/​issues/​detail?​id=5116|Issue 5116: IE x64 slow typing]] 
 +  - [[https://​code.google.com/​p/​selenium/​issues/​detail?​id=6511|Issue 6511: IE11 exceptions with IEDriverServer:​ Unable to get browser]] 
 +  - [[http://​robotframework.org/​Selenium2Library/​doc/​Selenium2Library.html|Selenium2Library]] 
  
 =====    ===== =====    =====