Hey guys,this is Satyam and in today's blog we are going to discuss about automating the boring stuffs in Python.So first of all what do you mean by automation,automation refers to the process in which we write some code which automates some stuffs such as opening browser,opening instagram and logging in it.Automating stuffs in python is not a difficult task.Or I will say that it's a very easy task.
Testing is mainly divided into two streams or parts – one is functional and another one is non-functional. In functional, we have two types of testing.
Manual Testing : In manual testing, our main activity is write the test cases and these test cases will be executed manually by some resource that is Test engineer.
Automation Testing : In automation testing, all the manual test cases will be converted to Test scripts with the help of some tools like selenium, QTP, RFT etc.
And now you may get one doubt i.e., in manual testing you are writing test cases and executing test cases and in automation you are doing the same activity, then why we use automation. So for clearing this doubt we will see advantages of automation.
Saves time Reduces Cost To Company(CTC) Maintain accuracy Scripts are repeatable Identifying bugs Better quality
Now we will discuss about browser automation.
Why Browser Automation ?
Testing Web Applications Web Scraping Automate anything
Now we will learn how to automate the web browser testing using the Selenium Framework.Selenium supports all major browsers such as Google Chrome,Firefox,Safari,Internet Explorer and Opera Browser and It also supports programming lnaguages such Java, C#, Ruby, Python, PHP, Perl, Scala and Groovy.Nearly all major Languages are supported by Selenium.
First of all all we will need to install Chrome Web Drivers and to install the chrome web drivers you can go to this link.
After installing the Web Drivers you need to install selenium using the pip package manager.
pip install selenium
Test Driving a Headless Browser
To test that everything is working, you decide to try out a basic web search via Bing. You fire up your preferred Python interpreter and type the following:
from selenium.webdriver import Firefox from selenium.webdriver.firefox.options import Options opts = Options() opts.set_headless() assert opts.headless browser = Firefox(options=opts) browser.get('https://bing.com')
from selenium import webdriver driver = webdriver.Firefox() driver.get("https://www.bing.com/") element = driver.find_element_by_id("newtab-search-text") element.send_keys("youtube")
So this is the end.This blog is Complete Hope you liked it.