Fetch data from mysql and use it in Selenium tests
Sometimes our tests cannot become reliable if we don’t use some data from the database , you might have to fetch data from mysql and use it in Selenium tests. On every project that I’ve worked I have to create a database helper and fetch different data and use it in my selenium tests.
You need to have installed a mysql client on your machine , here is how to install mysql on linux and here is how to install mysql on mac, on windows should be pretty similar and much simpler I guess.
Install mysql gem file
gem install mysql
Create a database helper
Your database credentials are stored inside /features/support/config.yml
And here is your cucumber step :
From now on , the world it’s yours!
If you are wandering where to chunk your module into the structure , you can have a look at one of the previous article about ruby watir page object structure.