Because I want my tests to cover an entire site, I installed wp-browser in the WordPress site root folder using the following composer.json file. This is the final version of this and also includes the suggested scripts from Inifinum.
If you’re already using wp-browser, you can add in the WebDriver dependency:
To use WebDriver, I had to install both Selenium and ChromeDriver. I followed these directions from Inifinum for installation. I won’t have to do this again but I’ll need to remember that Selenium server is running for everything to work: brew services start selenium-server-standalone
To my acceptance.suite.yml file, I added the WPWebDriver config as below:
I added a TEST_SITE_WP_URL_WITH_PROTOCOL constant to my .env.testing file as the url requires a protocol, eg it requires “https://example.test” rather than “example.test” which is the TEST_SITE_WP_URL defined during the default setup process. (I wasn’t sure if I could simply add on the protocol to the TEST_SITE_WP_URL constant but decided against messing around with things that were already working.)
The port needs to be the port which Selenium server is using.
I am *not* running headless as it helps me to see it as it goes along. I’m absolutely sure I will change this at some point. When I do, I’ll add “–headless” to the capabilities.chromeOptions.args array.
A note: only one of WPWebDriver or WPBrowser should be enabled per suite. The comments in the default setup say to create a separate suite for the other if you need to use both.
Join the newsletter
Subscribe to get the latest content by email.
Powered by ConvertKit. If you give me your email address, you may receive emails from me (JJ) about posts on this site. You can unsubscribe at any time.