This short tutorial will show you how you can write an e-mail using the Google’s GMail, by automating the browser itself.
The end result should look like:
And, like in the recording, it needs to be fully automated. All you need installed beside Python (2 or 3, both are supported) is Germanium:
pip install germanium
We’ll start simple by just including the required germanium API, and by opening the browser:
from germanium.static import *
We obviously need to go to the GMail website:
Then we go and fill in our credentials. In order not to have them available as plain/text in the test code, we will use some environment variables. This is great because we can reuse this script also on our CI machine, or even Germanium docker containers.
from os import env
Now that we’ve initiated the click, we need to wait for the page to load:
Wait, are we waiting on a custom button selector? Yes. We’ll define this selector as this function:
Then let’s compose an e-mail to ourselves. Spam is bad, spammers are horrible people, so we’re not going to spam anyone.
Now that we sent the e-mail we should wait for it to be sent:
wait(Text('Your message has been sent'))
Then just the cleanup:
Download the full script from here.