How to handle Google 2 steps authentication with selenium WebDriver
As many applications have 2 steps authentication to secure their data you might be the QA working on a project. So the question is how we are going to automate Google 2 steps authentication with selenium WebDriver?
Because no one has to suffer the guys from Gmail for ruby builded an awesome library that you can use to take the authentication code and use it to login with your selenium WebDriver tests.
The Solution for Google 2 steps authentication with selenium WebDriver
First of all
gem install gmail and second
Given a Ruby selenium WebDriver you can take as an example from one of our previous articles project your code should look something like this:
For me gmail for ruby has proven quite reliable in terms of 2 steps authentication and I used it also for forgotten password , contact forms etc.
The example shows you how you can do it in case of google authenticator or any other mechanism of 2 steps authentication. If your logic is builded in house I would suggest you to get the code from the db as is faster and you tests the email logic just once to make sure doesn’t get broken.
I hope this article has proven useful to you , till next week , Happy Testing!