WPSTestCase Class
When writing a WPSelenium test you need to extend the WPSTestCase class. This class extends phpunit's TestCase class and exposes the GetSeleniumDriver()
method. Use this method to get the facebook client driver for selenium. With this driver you can interact with your browser as needed in your tests.
Note: Since we are returning the facebook client driver for selenium, all the api calls documented there are also applicable here.
An example of how you would implement a wpselenium test class is below. As can be seen, this is similar to how you would implement a test case in phpunit. The only difference is the WPSTestCase class which exposes additional methods associated with testing with selenium.
<?php
use WPSelenium\WPSTestCase;
class SampleTest extends WPSTestCase{
function setUp()
{
$this->GetSeleniumDriver()->get($this->GetTestSite());
}
function testCanUserLogin(){
// TODO: Implement test
}
}
Note: wpselenium also runs none selenium phpunit tests. This means you can combine and run all your tests (selenium based and not) using wpselenium.