差異處

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

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
rf:rf:migratetoselenium2library [2016/03/04 13:48]
tony [Input Text]
rf:rf:migratetoselenium2library [2023/06/25 09:48] (目前版本)
行 2: 行 2:
 ====== Migrate SeleniumLibrary to Selenium2Library ====== ====== Migrate SeleniumLibrary to Selenium2Library ======
 ===== Introduction ===== ===== Introduction =====
-分享從SeleniumLibrary(SL1)升級到Selenium2Library(SL2)的歷程與方法。+分享從SeleniumLibrary(SL1)升級到Selenium2Library(SL2)的歷程與方法。\\ 
 +\\ 
 +Note. 某一天看到Selenium2Library從3.0開始後,已經於自身library中提供wrapper的實作,要升級的人可以嘗試看看。[[http://​robotframework.org/​Selenium2Library/​Selenium2Library.html|link]] 
 ===== Browser ===== ===== Browser =====
 由於SL1與SL2支援的瀏覽器版本有差異存在,有考慮過使用[[rf:​rf:​usecustomizedfirefox|portable的firefox]],但發現難以支援所有需要的作業系統。因此最無痛的方式,就是透過Remote Selenium,可參考[[rf:​rf:​seleniumgrid|此篇]]教學。 由於SL1與SL2支援的瀏覽器版本有差異存在,有考慮過使用[[rf:​rf:​usecustomizedfirefox|portable的firefox]],但發現難以支援所有需要的作業系統。因此最無痛的方式,就是透過Remote Selenium,可參考[[rf:​rf:​seleniumgrid|此篇]]教學。
行 38: 行 41:
 首先是輸入特定字串,無法正常輸入。 這個可以直接看我po在GitHub的issue:​\\ 首先是輸入特定字串,無法正常輸入。 這個可以直接看我po在GitHub的issue:​\\
 https://​github.com/​robotframework/​Selenium2Library/​issues/​582。\\ https://​github.com/​robotframework/​Selenium2Library/​issues/​582。\\
 +再來是輸入檔案路徑,例如:​
 +<​code>​
 +Input Text | ${xpath} | \\10.134.14.212\iso\Linux\CentOS\5.4\CentOS-5.4-x86_64-bin-DVD.iso
 +</​code>​
 +在Windows上會出現以下錯誤:​
 +<​code>​
 +LargeZipFile:​ Filesize would require ZIP64 extensions
 +</​code>​
 +我想這與Input Text實作方式有關,Choose File的內涵也是透過Input Text;假設內容為一個路徑且存在,也許就會把它當上傳檔案去做相關操作了。 而針對這個問題,我是透過Execute Javascript去做workaround,透過JQuery取得element by name,將內容修改為我要的內容:​
 +<​code>​
 +Execute Javascript | $("​[name='​xxxx'​]"​).val('​${val}'​);​
 +</​code>​
 +===== 其它問題 =====
 +==== StaleElementReferenceException:​ Message: Element is no longer attached to the DOM ====
 +更新為SL2後,常會在不定位置出現StaleElementReferenceException。[[http://​stackoverflow.com/​questions/​5709204/​random-element-is-no-longer-attached-to-the-dom-staleelementreferenceexception|爬文]]後,別人是說某個節點還不是有效時就去操作它而導致的。因此必須先透過Wait Until相關keywords等待節點出現後,再進行操作。\\
 +[[http://​www.seleniumhq.org/​exceptions/​stale_element_reference.jsp|more..]]
 +==== Firefox無法點擊可視範圍外的DOM element ====
 +以下是我使用會有問題的版本資訊:​
 +  * selenium: 3.8.0。
 +  * seleniumLibrary:​ 3.0.0。
 +  * selenium-server-standalone:​ 3.8.1。
 +  * geckodriver:​ 0.19.0、0.19.1。
 +  * firefox: 57.0.2、57.0.4。
 +同樣的selenium版本下,chrome沒這問題:​
 +  * chrome: 63.0.3239.84。
 +  * chromedriver:​ 2.34.522940。
 +起初解決這問題使用scrollbar控制可視範圍,但實在太麻煩,所以改使用chrome去測試。
 ===== Reference ===== ===== Reference =====
   * [[https://​github.com/​robotframework/​Selenium2Library/​wiki/​Differences-From-SeleniumLibrary|Differences From SeleniumLibrary]]   * [[https://​github.com/​robotframework/​Selenium2Library/​wiki/​Differences-From-SeleniumLibrary|Differences From SeleniumLibrary]]