This short repository contains an example of a WebDriver test that runs in a running instance of Chrome on Codeship.io.
The test is in the
How to run the test locally
To run the test locally follow the following steps:
- Clone the repo in some local folder:
git clone https://github.com/tidoust/codeship.git
- Install Composer if needed:
curl -sS https://getcomposer.org/installer | php
- Install PHP dependencies:
- Download ChromeDriver
- Run ChromeDriver in the background, the server should start listening on port 9515
- Run the test:
This should open up a Chrome instance that will load GitHub's home page and assert that the title is the right one.
How to run the test on Codeship
Create a new project associated with your cloned repository.
In Modify your Setup commands, enter:
# Set php version through phpenv. 5.3, 5.4 and 5.5 available phpenv local 5.4 # Install dependencies through Composer composer install --prefer-source --no-interaction # Run ChromeDriver nohup bash -c "chromedriver 2>&1 &" && sleep 4; cat nohup.out
In Modify yout Test commands, enter:
That's it, Codeship will run the test accordingly.
- If you prefer to plan another Web browser, you'll have to download and start the standalone WebDriver server instead
- It would be wise not to hardcode the URL of the ChromeDriver server in each and every test and use a constant instead
- Similarly, it might be better to keep the
webDrivervariable around instead of launching Chrome for each and every test