docker run -ti --rm -v $PWD:/wd/code kcmerrill/webdriver phpunit
The above command I have as an alias to phpunit.
All this command does is simply run php and FB webdriver. Write your tests like you normally would, however, here is a quick example of what your test should look like(at least the header portion).
This is how you get your selenium grid working:
docker run -d -p 4444:4444 --name selenium-hub selenium/hub
docker run -d --link selenium-hub:hub selenium/node-chrome
docker run -d --link selenium-hub:hub selenium/node-firefox
In a php file(for this example lets use mycoolnewtest.php), put the following contents:
<?php
require_once('/wd/vendor/autoload.php');
class SomeTest extends PHPUnit_Framework_TestCase {
protected $wd = false;
public function setUp() {
/*Note, change localhost to the ip address of your machine where docker is installed and the above 3 grid commands were run(if not localhost)*/
$this->wd = RemoteWebDriver::create('http://localhost:4444/wd/hub', DesiredCapabilities::firefox());
//$this->wd->manage()->timeouts()->implicitlyWait = 0;
}
public function testGitHubHome() {
$this->wd->get('https://github.com');
// checking that page title contains word 'GitHub'
$this->assertContains('GitHub', $this->wd->getTitle());
}
}
To run the test:
docker run -ti --rm -v $PWD:/wd/code kcmerrill/webdriver phpunit mycoolnewtest.php
Content type
Image
Digest
sha256:9198c00de…
Size
222.9 MB
Last updated
over 10 years ago
docker pull kcmerrill/webdriver