Some basic Advantages of automation testing are as follows.
- Automation testing supports both functional and performance test on an application.
- It supports the execution of repeated test cases.
- It facilitates parallel execution.
- It aids in testing a large test matrix.
- It improves accuracy because there are no chances of human errors.
- It saves time and money.
Lists of some commonly used Automation Testing tools for Non-Functional Automation are as follows.
- Load Runner, provided by Hp.
- JMeter, provided by Apache.
- Burp Suite, provided by PortSwigger.
- Acunetix, provided by Acunetix.
Selenium is a portable framework for software testing. Selenium tool facilitates with a playback tool for authoring functional tests without the need to learn a test scripting language.
Selenium is one of the most widely used open source Web UI (User Interface) automation testing suite. Jason Huggins developed Selenium in 2004 as an internal tool at Thought Works. Selenium supports automation across different browsers, platforms, and programming languages.
Selenium is not just a single tool but a suite of software’s, each having a different approach to support automation testing. It comprises of four major components which include:
- Selenium Integrated Development Environment (IDE)
- Selenium Remote Control (Now Deprecated)
- Selenium Grid
Selenium supports various operating systems, browsers and programming languages. Following is the list:
- Operating Systems: Android, iOS, Windows, Linux, Mac, Solaris.
- Browsers: Google Chrome, Mozilla Firefox, Internet Explorer, Edge, Opera, Safari, etc.
JUnit annotations which can be used are:
- Version 1.0 was the initial release of Selenium.
- It included three tools: Selenium IDE, Selenium RC, and Selenium Grid.
- Selenium WebDriver was introduced replacing Selenium RC in version “2.0”.
- With the onset of WebDriver, RC got deprecated and moved to the legacy package.
- The latest release Selenium 3 has new added features and functionalities.
- It includes Selenium IDE, Selenium WebDriver, and Selenium Grid.
Selenium Webdriver introduces the concept of waits for the AJAX-based application. There are two types of waits:
- Implicit Wait
- Explicit Wait
Selenium can be used to automate functional tests and can be integrated with automation test tools such as Maven, Jenkins, &Docker to achieve continuous testing. It can also be integrated with tools such as TestNG, &JUnit for managing test cases and generating reports.
WebDriver supported “mobile testing drivers” are:
Different types of testing’s that we can achieve through Selenium are.
- Functional Testing
- Regression Testing
- Sanity Testing
- Smoke Testing
- Responsive Testing
- Cross Browser Testing
- UI testing (black box)
- Integration Testing
The main disadvantage of implicit wait is that it slows down test performance.
Another disadvantage of implicit wait is:
Suppose, you set the waiting limit to be 10 seconds, and the elements appear in the DOM in 11 seconds, your tests will be failed because you told it to wait a maximum of 10 seconds.
The assertion is used as a verification point. It verifies that the state of the application conforms to what is expected. The types of assertion are “assert”, “verify” and “waitFor”.
Selenium WebDriver supports the below languages to write Test Cases.
Selenium IDE is implemented as Firefox extension which provides record and playback functionality on test scripts. It allows testers to export recorded scripts in many languages like HTML, Java, Ruby, RSpec, Python, C#, JUnit and TestNG.
Selenium IDE has limited scope, and the generated test scripts are not very robust, and portable.
Benefits of Automation testing are as follows.
- It allows execution of repeated test cases
- It enables parallel execution
- Automation Testing encourages unattended execution
- It improves accuracy. Thus, it reduces human-generated errors
- It saves time and money.
Assert: Assert command checks if the given condition is true or false. If the condition is true, the program control will execute the next phase of testing, and if the condition is false, execution will stop, and nothing will be executed.
Verify: Verify command also checks if the given condition is true or false. It doesn’t halt program execution, i.e., any failure during verification would not stop the execution, and all the test phases would be executed.
XPath is also defined as XML Path. It is a language used to query XML documents. It is an important approach to locate elements in Selenium. XPath consists of a path expression along with some conditions. Here, we can easily write XPath script/query to locate any element in the webpage. It is developed to allow the navigation of XML documents. The key factors that it considered while navigating are selecting individual elements, attributes, or some other part of an XML document for specific processing. It also produces reliable locators. Some other points about XPath are as follows.
- XPath is a language used for locating nodes in XML documents.
- XPath can be used as a substitute when you don’t have a suitable id or name attribute for the element you want to locate.
- XPath provides locating strategies like:
- XPath Absolute
- XPath Attributes
Selenium commands, also known as “Selenese” are the set of commands used in Selenium that run your tests. For example, command – open (URL); launches the desired URL in the specified browser and it accept both relative and absolute URLs.
A sequence of Selenium commands (Selenese) together is known as a test script.
- XPath Absolute enables users to mention the complete XPath location from the root HTML tag to the specific elements.
- Syntax: //html/body/tag1[index]/tag2[index]/…/tagN[index]
- Example: //html/body/div/div/div/div/div/div/fieldset/form/div/input
- XPath Attributes is always recommended when you don’t have a suitable id or name attribute for the element you want to locate.
- Syntax: //htmltag[@attribute1=’value1′ and @attribute2=’value2′]
- Example: //input[@id=’passwd’ and @placeholder=’password’]
“type” command is used to type keyboard key values into the text box of software web application. It can also be used for selecting values of combo box whereas “typeAndWait” command is used when your typing is completed and software web page start reloading. This command will wait for software application page to reload. If there is no page reload event on typing, you have to use a simple “type” command.
In Selenium, web elements are identified and located with the help of Locators. Locators specify a target location which uniquely defines the web element in the context of a web application. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:
- CSS Selector
Single Slash “/”: Single slash is used to create XPath with absolute path.
Double Slash “//”: Double slash is used to create XPath with the relative path.
findElement(): It is used to find the first element within the current page using the given “locating mechanism”. It returns a single WebElement.
findElements(): It uses the given “locating mechanism” to find all the elements within the current page. It returns a list of web elements.
The list of WebDriver API’s which are used to automate browser include: