加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 使用Maven,Protractor和Selenium WebDriver进行集

发布时间:2020-12-17 18:09:08 所属栏目:安全 来源:网络整理
导读:我们开发了一个Web应用程序,它在后端使用 Java,在Angular中使用UI,使用Maven作为构建系统. 我一直在尝试使用Protractor设置自动集成测试,并且在加载Googling / StackOverflowing之后仍然无法弄清楚如何实现端到端配置. Node.js / NPM安装(失败) 我已经尝试使
我们开发了一个Web应用程序,它在后端使用 Java,在Angular中使用UI,使用Maven作为构建系统.

我一直在尝试使用Protractor设置自动集成测试,并且在加载Googling / StackOverflowing之后仍然无法弄清楚如何实现端到端配置.

Node.js / NPM安装(失败)

我已经尝试使用frontend-maven-plugin来处理Node.js和NPM安装,但由于我们是在公司防火墙后面,所以似乎无法直接下载任何东西.它可以从我们的Artifactory下载Node但是在NPM下载时失败了(我不明白为什么它甚至下载它因为它是Node包的一部分).无论如何,我放弃了这个想法,并决定使用本地安装的Node.

启动Tomcat

启动/停止用于e2e测试的Tomcat实例可以很好地处理

<plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>${tomcat.manager.url}</url>
                <path>/</path>
                <server>Tomcat</server>
            </configuration>
            <executions>
                <!-- Starting Tomcat -->
                <execution>
                    <id>start-tomcat</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <!-- Fork the process,otherwise the build will be blocked by the running Tomcat -->
                        <fork>true</fork>
                        <port>${tomcat.port}</port>
                        <systemProperties>
                            <!-- We want to use the 'e2e' profile for integration testing -->
                            <spring.profiles.active>e2e</spring.profiles.active>
                        </systemProperties>
                    </configuration>
                </execution>
                <!-- Stopping Tomcat -->
                <execution>
                    <id>stop-tomcat</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>shutdown</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

使用WebDriver(失败)

我设法启动WebDriver,但问题是它阻止了任何进一步的执行:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
                <!-- Start webdriver -->
                <execution>
                    <id>start-webdriver</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>webdriver-manager</executable>
                        <arguments>
                            <argument>start</argument>
                        </arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>

运行量角器

鉴于安装了Node.js并且WebDriver正在运行,这应该不是问题.但由于我无法启动WebDriver以便继续执行,因此会被阻止.

有关WebDriver如何管理(启动/停止)的任何建议?

解决方法

将directConnect:true添加到Protractor配置文件中可以解决启动/停止WebDriver的问题(如Nick所建议的).在这种情况下,必须从POM中删除对WebDriver的任何显式控制.

可用参数在reference configuration file中有详细说明.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读