There are many ways to skin a cat and trying to use Selenium with WordPress CLI is new to me. Essentially, WordPress is ‘just’ a dynamic website using a SQL database with some themes and plugin files behind it.
June 2020 - this article is out of date - checkout my newer posts on Automated Testing
Selenium is designed as a frontend browser test tool so keep that in mind for a minute and I assume you mean Selenium IDE. The result would be very brittle test cases if you built something up with Selenium IDE + WordPress CLI.
What is Brittle? Hard to maintain, test cases that need to be adjusted everytime you try to run them, a lot more test fails then passes.
Given your experience of testing is probably more than mine (which is easy) - I’d recommend you look at python or php and connect to the mySQL database and not use WP CLI (or start by having SequelPro or PHPMyAdmin running).
I believe this is what you are looking for as:
1 It separates the Front End user experience from the database 2 Your Selenium IDE test cases won’t need WP CLI 3 You won’t need to update your Selenium test cases as often as you probably do today 4 You can trigger pyhton / php unit tests from terminal 5 You can play around with database changes and just watch your Selenium test cases pass or fail 6 you can the just drop / reset your database table and start test cases again đ
PS - I’ve written about using ChromeDriver / Python / Selenium to do very basic browser tests for my WordPress site.
This answer of mine originally appeared on WordPress Answers / Stackexchange
Answer by Damien for Can I get at WordPress code from inside a Selenium test?:
Tags:Read more from my blog for an introduction and quick tips on developing in Hugo or UCTD.