Can I get at WordPress code from inside a Selenium test?

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.

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:

a. It separates the Front End user experience from the database b. Your Selenium IDE test cases won’t need WP CLI c. You won’t need to update your Selenium test cases as often as you probably do today d. You can trigger pyhton / php unit tests from terminal e. You can play around with database changes and just watch your Selenium test cases pass or fail f. 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: , ,