Test Automation, Wikipedia Navigation Example
This is a simple test that will navigate throught Wikipedia. To launch it, with Docker installed and ready, just run:
- docker run -t gopejavi/geb-wiki-example
There is no need to execute any additional command for running the tests, as Docker takes care of that.
If you want to check how the tests have been made (including Page Object pattern) you can check it at
where the file WikipediaTestSpec.groovy is the test entry point.
How Was Implemented
Basic steps taken:
- I donwloaded a Linux VM (next actions are done there).
- I learned basics for Docker and installed it.
- I studied the Page Object pattern.
- Then I learned how Geb works and how Spock lets us define tests in a BDD fashion.
- From Geb official repository, I downloaded a working example for Docker as a starting point. I modified it to only use the headless PhantomJS browser for better speed.
- Then I implemented the WikiTestSpec base.
- Finally, I modelized the different pages:
- Pages are modelized into files ending with "Page"
- Page pieces or sections are modelized into files ending with "Module".
- Modules are reused in Pages. For example, the english main Wikipedia page and MVVM page share the basic definitions for header and footer.
- I consider the header as correct if it has the personal area section within.
- I consider the footer as correct if it talks about the Creative Commons license somewhere.
Although there's no need to use it, I included it as is not in the tests repository and is part of the work:
# Easily run tests with Geb, Spock and PhantomJS FROM ubuntu:latest RUN apt-get update && apt-get install -y \ wget \ unzip \ git \ default-jre \ && rm -rf /var/lib/apt/lists/* #last line cleans apt cache so reduces Docker image size. # Gradle WORKDIR /usr/bin RUN wget https://services.gradle.org/distributions/gradle-4.0-all.zip && \ unzip gradle-4.0-all.zip && \ ln -s gradle-4.0 gradle && \ rm gradle-4.0-all.zip ENV GRADLE_HOME /usr/bin/gradle #RUN chmod +x /usr/bin/gradle ENV PATH $PATH:$GRADLE_HOME/bin # Put Gradle cache in /var so it can it is part of container ENV GRADLE_USER_HOME /var/cache/gradle # Prime the Gradle cache with dependencies needed to run simple Geb scripts WORKDIR /root RUN git clone https://github.com/gopejavi/GebExampleToTest.git WORKDIR GebExampleToTest #So it is faster when actually running, as dependencies are already in Docker image (has to be improved) RUN ./gradlew phantomJsTest #Output some info in the case some error happens CMD ./gradlew phantomJsTest --info