尝试使用 RobotFramework-Maven-Plugin 1.4.6 在 OS X El Capitan 10.11.6 上的 IntelliJ 2016.2 中的 Maven Java 项目中运行简单测试
http://robotframework.org/MavenPlugin/
如果测试是通过命令行使用机器人运行的,则测试将打开 Firefox 浏览器,运行并通过:
*** Settings ***
Library Selenium2Library
Suite Teardown Close all browsers
*** Variables ***
${BROWSER} firefox
${DOMAIN} google.com
${PAGE_TITLE} google
*** Test Cases ***
Example
Open browser http://${DOMAIN} ${BROWSER}
Page Should Contain ${PAGE_TITLE}
这是我收到的错误:
Importing test library 'Selenium2Library' failed: ImportError: No module named decorator
这是我的 pom.xml 的重要部分:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
<plugin>
<groupId>org.robotframework</groupId>
<artifactId>robotframework-maven-plugin</artifactId>
<version>1.4.6</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.github.markusbernhardt</groupId>
<artifactId>robotframework-selenium2library-java</artifactId>
<version>1.4.0.8</version>
</dependency>
</dependencies>
按照 RobotFramework Maven 插件站点的规定,我在/src/test/resources/robotframework/libraries/下有最新的 Selenium2Library 1.8.0:http://robotframework.org/MavenPlugin/examples/seleniumlibrary.html
我一整天都在解决这个问题并进行了搜索,最后陷入了死胡同。任何帮助将不胜感激。
最佳答案
我发现我做错了什么,我仍然没有运行测试,但我已经解决了这个问题。基本上,如果您使用 RobotFramework Selenium2Library java 端口,则不再需要按照网站上有关在/src/test/resources/robotframework/libaries 下放置 Selenium2Library 的说明进行操作
您不需要在资源目录中包含 Selenium2Library,它由 Maven 依赖项处理。
关于java - "Importing test library ' Selenium2Library ' failed: ImportError: No module named decorator"RobotFramework maven插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40621698/