Selenium With Python
Selenium With Python
Selenium With Python
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Course Agenda
• Selenium Basics
• Selenium python basics
• Creating WhatsApp bot using selenium
• Web Scraping an e-commerce website
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
What is Testing ?
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
(What is Testing)
Once we develop a software component/ product, we have to analyze and inspect its features and
also evaluate the component for potential errors and bugs so that when it gets delivered in the
market, it is free of any bugs and errors. It is the point where we need extensive testing of the
software.
Testing is done when the application is build , is ready to test and deployed in the
test servers / environments.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
(What is Manual Testing ?)
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
(Manual Testing)
Manual testing means the (web) application is tested manually by QA testers. Tests need to be
performed manually in every environment, using a different data set and the success/ failure rate of
every transaction should be recorded.
Manual testing is mandatory for every newly developed software before automated testing. This testing
requires great efforts and time, but it gives the surety of bug-free software.
• GUI Objects Size difference and Color combinations etc.. are not easy to find in Manual Testing
• Executing the same tests, again and again, is time taking process as well as Tedious.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
(Automation Testing)
As the name suggests. automation testing takes software testing activities and executes them via an
automation toolset or framework. In simple words, it is a type of testing in which a tool executes a set of
tasks in a defined pattern automatically.
This automation testing method uses scripted sequences that are executed by testing tools. Automated
testing tools execute examinations of the software, report outcomes and
compare results with earlier test runs.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
(What is Selenium?)
Selenium was introduced by Jason Huggins in 2004. Jason Huggins an Engineer at Thoughtworks. He was
doing his work on some web application and he suddenly required testing.
Selenium is an open-source tool and portable framework that is used for automating the tests
administered on web browsers. It is only used for testing web applications
such as Shopping Carts, Email Programs like Gmail, Yahoo.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
(Why Selenium with python ?)
• Python runs very faster and makes use of indentation to initiate and end blocks. It is very simple as well as
compact as compared to other programming languages.
• The most important tool for easy user interfaces that is WebDriver has strong bindings for Python.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
(Advantages of Selenium Testing)
• Selenium supports various browsers like Mozilla Firefox, Google Chrome etc.
• Selenium supports different operating systems like Windows, Linux, Mac etc.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
(Limitations of Selenium Testing)
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Selenium suite of tools
Selenium is a tool having lot of software which have a different method for supporting
the automation testing technique . It comprises of four major components which include:
3.Selenium WebDriver
4.Selenium Grid
Selenium IDE
Selenium integrated tool is the easiest web automation tool present in the selenium suite. It is very
easy to learn.
It is an add-on of Firefox so that tests are created quickly through its works and functionality. This
feature is similar to QTP (Quick Test Professional).
It is so simple, and thus, is only used for prototyping tools and not
for developing complex test suites.
Selenium GRID
Selenium WebDriver
Selenium WebDriver is an open-source assemblage of API’s and it is the most important component of
Selenium Tool’s Suite. It is used for testing web applications. WebDriver API is integrated with the latest
release of selenium which is “Selenium 2.0” provided with a simpler and a condensed programming
look.
Test Scripts in Selenium WebDriver can be developed with any supported
programming language and can be executed in any modern or fancy browsers.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
get method
get() is used to navigate particular URL(website) and wait till page load.
WebDriver will wait until the page has fully loaded before returning control to your test or script.
Syntax :
driver.get(url)
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Selenium Locators
Selenium Locators
Selenium gives user options to locate elements in different ways.
•Id
•Name
•Linktext
•Partial Linktext
•Tag Name
•Class Name
Locate element by ID
Locating by ID is the most frequent method of locating elements. But IDs are supposed
to be unique.
Syntax :
findElement(By.id(“ ”))
This is a fall back option when Id for element is not present. But mostly the
names are used again and again, so make sure that the name is unique on the
page before using it.
Syntax :
findElement(By.name(‘ ’))
LinkText helps to find the hyperlink on a webpage. We use the anchor tag to
locate the element using LinkText.
Syntax :
findElement(By.linktext(‘Link’));
In a LinkText element , sometimes we could need to find the link by the portion of a
text.
Therefore in the above mentioned condition we use the Partial LinkText.
Syntax :
findElement(By.partialLinkText(‘Link’))
Tag Name we can use for the elements like drop downs, check boxed, radio buttons.
Following html is for drop down with 3 values. To select that drop down we will use
tag Name locator.
Syntax :
findElement(By.tagname(“ ”))
This locator we can use as a fall back option for either name or Id. But the
same condition applied here Class name should be unique or selenium will
locate the first element present on the page with the class name we have
used to locate element.
Syntax :
findElement(By.classname(“ ”))
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Pytest
• Open-source library
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited