2017-08-26 38 views
2

我想通過在Java中使用Selenium WebDriver實現新的Robot Framework關鍵字來擴展Selenium2Library python庫(1.8.0)。如何通過使用Java中的Selenium WebDriver創建新的RobotFramework關鍵字來擴展Selenium2Library

爲了做到這一點,我需要能夠檢索我的Java關鍵字中的Selenium2Library python庫使用的WebDriver實例。

請注意,我不想使用由Markus Benhardt創建的Selenium 2(WebDriver)Python庫的Java端口,因爲它基於舊版本的Selenium2Library,因此它顯然已過時。

我聽說用Jython 2.7,我們現在可以在Java上使用Python版本的Selenium2Library ...但是我的問題是......怎麼樣?

我的設置是使用:

這裏是我的pom.xml

<plugin> 
    <groupId>org.robotframework</groupId> 
    <artifactId>robotframework-maven-plugin</artifactId> 
    <version>1.4.7</version> 
    <configuration> 
     <extraPathDirectories> 
      <extraPathDirectory>/usr/local/lib/python2.7/site-packages</extraPathDirectory> 
     </extraPathDirectories> 
    </configuration> 
    <executions> 
     <execution> 
      <goals> 
       <goal>run</goal> 
      </goals> 
     </execution> 
    </executions> 
    <dependencies> 

     <!-- Robot Framework - High level test automation framework --> 
     <dependency> 
      <groupId>org.robotframework</groupId> 
      <artifactId>robotframework</artifactId> 
      <version>3.0.2</version> 
     </dependency> 

     <!-- Selenium Server --> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-server</artifactId> 
      <version>2.53.1</version> 
     </dependency> 
    </dependencies> 
</plugin> 

的提取物有沒有人做過類似的東西?

回答

0

您希望獲得Java解決方案,但聽起來您更喜歡呆在Python上下文中。在Robot Framework中,應用程序robot(Python)調用Selenium2Library(Python),後者又調用selenium(Python)語言綁定模塊,並導致向瀏覽器WebDriver發送消息。

正如您所看到的,典型的Robot Framework安裝中不需要Java。如果你想擴展Python模塊selenium,那麼看看robotframework-extendedselenium2library這是一個很好的例子。

0

即使我有類似的情況,我必須使用Java與Robotframework。通過使用適用於Java的Robot Selenium2library,可以鏈接關鍵字。

您也可以創建自定義關鍵字,然後將它們鏈接到Java類以實現其各自的實現。

嘗試尋找在項目下面

https://github.com/mskumar1809/StraitTimesAppiumRobot

這對於機器人的自定義關鍵字提供的Java實現不依靠過時的Java庫

機器人
相關問題