Skip to content

Instantly share code, notes, and snippets.

@rebel1324
Last active June 10, 2021 08:19
Show Gist options
  • Save rebel1324/cc986f989c77c84df36355f2730f5c03 to your computer and use it in GitHub Desktop.
Save rebel1324/cc986f989c77c84df36355f2730f5c03 to your computer and use it in GitHub Desktop.
How to use WDIO Docker

How to use Webdriver.io Docker Image

What is this?

Webdriver.io is something like nightwatch.js. It allows you to do the cross-platform testing with the provided test case. Nothing is special.

But, here is the deal - You can setup e2e test without spending your time figuring out what to install, what to run, where to save the test case. This is huge. I mean setting up the project is the notorious time vampire you can imagine.

The docker image

https://github.com/blueimp/wdio Thankfully, @blueimp gave us the good docker image sets that help us to setup e2e test easily. But, Unfortunately, There is lack of "how to install" document so i've decided to leave some steps i've been through to save other people's time.

Getting started

Clone the repository

First of all. you need to clone the whole git repository in your local machine (or remote machine)

git clone https://github.com/blueimp/wdio.git ?some directory?

Resolving certificate issue

If you're behind the company's firewall, you're going to have some trouble to fire up the project. In this case, you need to mount your certificate directory to resolve the SSL issue. add /etc/ssl/certs:/etc/ssl/certs:ro to all docker-compose services. The cerificate location may varies depends on the machine. Unfortunately, I don't know the case if the host machine is windows. I suggest you to use Vagrant or VirtualBox to manage this issue.

After that go to the src directory, and find the Dockerfile and replace pip install itsdangerous to RUN python3 -m pip --trusted-host pypi.org --trusted-host files.pythonhosted.org install itsdangerous to not have a headache. Then voila! most of the certificate issues are gone.

Enjoy

run docker-compose run --rm wdio [wdio.conf.js] to commence the test. The detailed information is in the repository.

Oh, don't forget to remove []!. Apparently they're for displaying where to put the paramters.

For Vagrant Users

DO NOT npm install inside of the shared directory!!

It will not work and waste your time figuring out what's wrong. If npm install is not working at all, I suggest you to temporaily move the project to the non-shared directory and run the command to install the npm packages. After the installation, move the project back to the shared directory for ease of development.

CJK Charset

The webdriver image does not have proper CJK charset, I suggest you to include the font in the site to not see some nasty tofu.

Webdriver.io 도커 이미지 사용 방법

개요

Webdriver.io는 nightwatch.js나 셀레니움 같이 웹 테스트를 도와주는 프레임워크입니다.

하지만, 이것들을 세팅하는데에는 오랜 시간이 걸리고 머리가 아프고 집에 가고싶어집니다.

그래도 이것들을 해결해주기 위한 것이 있으니 한번 확인해보시는게 어떤가요

도커 이미지

https://github.com/blueimp/wdio 감사하게도, @blueimp라는 분이 도커 이미지를 만들어 주셔서 제 일주일을 아껴주셨습니다. 하지만, 사용법이 자세하게 적혀있지 않아 사용을 안하시거나 중도 포기하시는데 저도 할뻔했다가 그냥 글을 남기게 되었습니다.

사용 방법

Repository 복제

먼저, Git Repository를 로컬(또는 원격)컴퓨터에 복제하세요

git clone https://github.com/blueimp/wdio.git ?대상 폴더?

인증서 문제 해결

만약 회사 방화벽으로 인해서 SSL이 제대로 되지 않는다면, 추가적으로 해야할게 있습니다. /etc/ssl/certs:/etc/ssl/certs:ro를 모든 docker-compose.yml에 추가해주세요. 인증서 주소는 OS마다 다를수 있지만, Window 호스트 머신의 경우에는 제가 아는게 없습니다. Windows를 사용하시는 경우에는 VagrantVirtualBox를 사용하여 Linux를 사용하시는 것을 추천드립니다.

그리고 src폴더의 Dockerfilepip install itsdangerousRUN python3 -m pip --trusted-host pypi.org --trusted-host files.pythonhosted.org install itsdangerous로 교체해주세요.

테스트 시작

docker-compose run --rm wdio [wdio.conf.js]를 실행하여 테스트를 진행하세요. 더 자세한 실행법은 Repository의 README.md에 있습니다.

그리고 []를 뺴는것을 잊지 마세요. 어디다가 뭘 넣어야할지 표시하는데 사용된거라 [] 넣으면 작동 안합니다.

Vagrant 사용자

공유 디렉토리에서 npm install를 실행하지 마세요 !!

안됩니다. 공유 디렉토리가 아닌 곳에서 npm install 또는 위에 있는 명령어를 실행하시고 다시 원격 디렉토리에 돌려놓는게 정신건강에 매우 좋습니다.

CJK 폰트

웹드라이버가 해당 폰트를 가지고 있지 않기 때문에, 테스트할 서비스에 CJK 폰트를 미리 탑재하시는 게 좋습니다. Google의 NotoSans를 이용하시는 경우에는 문제 없습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment