I've been reading about DevOps and Automation using Terraform, Ansible, and CI/CD tools. but, I heard that tools like selenium often used by the QA team to perform automated web testing. But, I am always fascinated when I am hearing the words “selenium test cases” that are buzzing around me sometimes and I'm a freaking Instagram Addict and I always think about how to reach people to show off my photography skill. Though I've decided to build my own Instagram Bot to reach my followers and like their posts, etc.
In this blog, I've wanted to explain how selenium works with python scripting. Le's dig in,
So, What is selenium?
I leave the question with you and Let’s begin with the installation of the dependencies and required tools.
1. Install the “python selenium” (https://selenium-python.readthedocs.io/) package via your command prompt.
– pip install selenium
sometimes depending on your python and pip version you may need to issue,
– pip3 install selenium
2. Install the chrome web driver (https://sites.google.com/a/chromium.org/chromedriver/downloads). Select the driver matching the exact version of your chrome browser. To view the chrome browser version, click on Help -> About Google Chrome
That's pretty much it. let's move on to the code,
Import all the required libraries as indicated in the below diagram.
Provide the path location of the downloaded “Google chrome driver” as indicated in the following diagram. Make sure to convert the “\” to “/”
In order to find the relevant HTML element for input, use the “inspect” option by right-clicking on the web page as shown below in the diagram.
“WebdriverWait” is used to wait until the dynamic HTML element appears on the html page. If not accessing the element will output an error. Then after moving to the next page, we need to provide the password for the email. So once again we have to follow the same steps as explained above to insert the password into input field and to click on next button. After login in successfully, we can able to open our “Instagram Account” page.
Thus, through this type of automation, we can test our application on different versions of Chrome browsers and in different web browsers like Firefox and Internet Explorer seamlessly.
Code can be found here
People don't know python and stuff
download the code from the repo and below mention things
1. Download python to your PC tutorial
2. Then open your terminal or CMD and install selenium
– pip install selenium (mentioned above)
3. change the line of the code at line 165
if __name__ == "__main__":
username = "you user name"
password = "your password"
4. In your terminal or CMD type
python igm.py
That's pretty much it!
No comments:
Post a Comment