Automating the Boring Stuff
Tags: python
Published: 2020-09-21 09:48:06

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.

#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.
#Browser Automation

Browser automation tools can automate your Web browser to perform repetitive and error-prone tasks, such as filling out long HTML forms. Web browser automation tools work by recording the series of steps that make up a specific transaction, and then play it back by injecting JavaScript into the target web pages, and then tracking the providing the results. These web automation tools resemble macros, but are much more flexible and sophisticated.
Why Browser Automation ?

#We use browser automation for the following reason –

    Testing Web Applications
    Web Scraping
    Automate anything 

#Automation Testing With Selenium

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.
#SET UP

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.
Web Drivers

After installing the Web Drivers you need to install selenium using the pip package manager.
pip install selenium
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')
```

#EXAMPLE 

```
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.

My Portfolio:[skv.netlify.com]

Python Tutorial:[https://BestPythonTutorials.com] 


#Thanks for Reading