参考: https://www.youtube.com/watch?v=k5iwKUZY9tk
测试环境 mac
1 Get docker image.
$ docker pull chusiang/takaojs1607
1.1 原镜像较老 如果要用自己的镜像安装环境(略过)
安装selenium
sudo pip install selenium安装Chrome浏览器
sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
sudo apt-get install -f安装ChromeDriver
在运行过程中ChromeDriver会与Chrome浏览器不兼容,重新下载ChromeDriver地址
sudo apt-get install unzip
wget -N http://chromedriver.storage.googleapis.com/2.42/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
chmod +x chromedriver
sudo mv -f chromedriver /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
2 Get vnc port
docker port $(docker run –name e2e -d -P chusiang/takaojs1607) 5900
or
docker run –name e2e -d -P chusiang/takaojs1607
docker port e2e 5900
返回 0.0.0.0:32768
3 打开 Remote with VNC client(看测试效果)
open vnc://:secret@127.0.0.1:32768
开始测试
1 Enter e2e container.
$ docker exec -it e2e bash
2 Switch user wget
su - seluser
该用户下已经有测试代码
3 进入安装环境 并运行
ls && cd angular-seed/ && npm run start &
4 Run e2e test 运行测试
npm run protractor