Running Protractor Tests on Docker

配置这个Protractor环境真是折磨死人了,webdriver-manage update怎么都不成功,即使自己下载好chromederiver放到相应文件夹下,也不能使用。费时三四天终于按照https://github.com/angular/protractor-cookbook/tree/master/protractor-docker这里的方法弄好了

首先你得确保安装了docker

docker -v

如果已经成功安装了会显示如下

Docker version 17.12.0-ce, build c97c6d6

Step 0 - Download the docker images for Selenium Hub and Selenium Node

docker pull selenium/hub:latest
docker pull selenium/node-chrome:latest

如果你想要使用firefox-node,可以pull 'node-firefox'。想要了解不同镜像的更多信息,可以查看Docker Selenium Images List

Step1 - Starting the Selenium Grid

docker run -d -p 4444:4444 --name selenium-hub selenium/hub:latest

One can change the tag from 'latest' to '2.53.0' or any other version as they see fit.

Step2 - Starting the Selenium Nodes

docker run -d --link selenium-hub:hub selenium/node-chrome:latest

The above would create a chrome node and link it to the Selenium hub/grid created earlier.

Step3 - Running the tests

更新配置文件中的SeleniumAddress如下:

seleniumAddress: 'http://localhost:4444/wd/hub'

运行测试文件

./node_modules/.bin/protractor protractor-conf.js

有时候会不支持es6的语法结构,可以先使用babel进行转码, 需要安装babel,babel-cli,babel-core,babel-preset-latest,babel-preset-stage-2等依赖,配置.babelrc文件。

babel-node ./node_modules/.bin/protractor protractor-conf.js

我的项目中package.json

.babelrc文件

 

转载于:https://www.cnblogs.com/xuepei/p/8423967.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值