首页 文章

如何使用Java中的Selenium WebDriver创建新的RobotFramework关键字来扩展Selenium2Library

提问于
浏览
2

我正在尝试通过在Java中使用Selenium WebDriver实现新的Robot Framework关键字来扩展Selenium2Library python库(1.8.0) .

为了做到这一点,我需要能够在我的Java关键字中检索Selenium2Library python库使用的WebDriver实例 .

请注意,我根据旧版本的Selenium2Library,因此它显然已经过时了 .

我听说过使用Jython 2.7,我们现在可以在Java上使用Selenium2Library的Python版本......但我的问题是......怎么样?

我的设置正在使用:

这是我的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>

有没有人做过类似的事情?

2 回答

  • 0

    你想要一个Java解决方案的愿望,但是我觉得你更喜欢呆在Python环境中 . 在Robot Framework中,应用程序 robot (Python)调用 Selenium2Library (Python),后者又调用 selenium (Python)语言绑定模块,并向浏览器发送消息 WebDriver .

    正如您所知,典型的Robot Framework设置中不需要Java . 如果你想扩展 selenium Python模块,那么看一下robotframework-extendedselenium2library,这是如何实现这一目标的一个很好的例子 .

  • 0

    即使我有类似的情况,我不得不使用Java与Robotframework . 通过使用Robot Selenium2library for Java可以实现关键字的链接 .

    您还可以创建自定义关键字,然后将它们链接到Java类以实现各自的实现 .

    试着看下面的项目

    https://github.com/mskumar1809/StraitTimesAppiumRobot

    它提供了Robot自定义关键字的java实现,而不依赖于Robot过时的Java库

相关问题