Objective Of Automation Testing
The objective of software testing is to discover faults and errors in a software application. Software testing utilizes more than 50 % time of the software development lifecycle. Testing time depends upon the algorithm used, programming language, line of codes, function points, external and internal interfaces. Testing improves the quality of an application. As compared to human testing, automatic testing is better, because automation testing systematizes the testing process of analysis, design, and coding of various scripts. Selenium is an open-source tool that is used for test automation of different types of online and real-time applications.
I am Souvik Naskar from my limited knowledge, I explained some key points where the beginners of the automation, can understand the basic knowledge of the Selenium tool.
Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. It is quite similar to HP Quick Test Pro (QTP now UFT) only that Selenium focuses on automating web-based applications.
- It has four
- Selenium Integrated Development Environment (IDE)
- Selenium Remote Control (RC)
- Selenium Grid
SELENIUM INTEGRATED DEVELOPMENT ENVIRONMENT (IDE)
The IDE is a Firefox plugin that permits testers to record their actions as they track the work process flow that they want to test. The main components of the Selenium IDE are as follows. Selenium IDE has a Menu bar, Base URL text box, Toolbar, Test Case pane, Command window, and test Run or Failure status section.
WebDriver is a web automation framework that allows you to execute your tests against different browsers, not just Firefox, Chrome. And also enables you to use a programming language in creating your test scripts.
Difference between Selenium RC and Web driver:-
Running Test on Different Browser:-
- Running a test on Chrome Browser:-
// System Property for Chrome Driver
WebDriver driver=new ChromeDriver();
- Running a test on FireFox Browser:-
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
WebDriver driver= new FirefoxDriver(capabilities);
- Running test on Safari Browser:-
// Instantiate a Safari Driver class.
WebDriver driver = new SafariDriver();
Selenium WebDriver- Commands:-
WebDriver is to open the Eclipse IDE loaded with Selenium Webdriver jar files, create a driver object for WebDriver and press the dot key. It will show you all of the possible methods provided by WebDriver.
Methods can return a value or returning nothing (void). If the void is mentioned after the method, it means, the method is returning no value. If it is returning a value, then it must display the type of the value for e.g. getTitle(): String.
Selenium WebDriver can be broadly classified in the following categories:-
- Browser Commands
- Navigation Commands
- WebElement Commands
Commonly used Selenium commands in WebDriver:
1. Fetching a web page
There are two methods to fetch a web page:
- Using the Get method
2. Using the Navigate method
driver.navigate().to(“https://www.amazon.in/“); Locating forms and sending user inputs
driver.findElement(By.id(“twotabsearchtextbox”)).sendKeys(“Apple MacBook Pro“);
3. Clearing User inputs
The clear() method is used to clear the user inputs from the text box.
4. Fetching data over any web element
Sometimes we need to fetch the text written over a web element for performing some assertions and debugging. We use getText() method to fetch data written over any web element.
5. Performing Click event
The click() method is used to perform click operation on any web element.
6. Navigating backward in browser history
7. Navigating forward in browser history
8. Refresh/ Reload a web page
9. Closing Browser
10. Closing Browser and other all other windows associated with the driver
11. Moving between Windows
12. Moving between Frames
Introduction of Locators and Eight Locating Techniques :-
TestNG is an automation testing framework in which NG stands for “Next Generation”. TestNG is inspired from JUnit which uses the annotations (@).
- Using TestNG you can generate a proper report, and you can easily come to know how many test cases are passed, failed and skipped.
- You can execute the failed test cases separately. For example.
- Suppose, you have five test cases, one method is written for each test case (Assume that the program is written using the main method without using TestNG). When you run this program first, three methods are executed successfully, and the fourth method is failed. Then correct the errors present in the fourth method, now you want to run only the fourth method because the first three methods are anyway executed successfully. This is not possible without using TestNG.
Default Selenium tests do not generate a proper format for the test results. Using TestNG we can generate test results.
Most Selenium users use this more than Junit because of its advantages. There are so many features of TestNG, but we will only focus on the most important ones that we can use in Selenium. Following are key features of TestNG
- Generate the report in a proper format including a number of test cases runs, the number of test cases passed, the number of test cases failed, and the number of test cases skipped.
- Multiple test cases can be grouped more easily by converting them into the testng.xml file. In which you can make priorities which test case should be executed first.
- The same test case can be executed multiple times without loops just by using a keyword called ‘invocation count.’
- Using TestNG, you can execute multiple test cases on multiple browsers, i.e., cross-browser testing.
- The testing framework can be easily integrated with tools like Maven, Jenkins, etc.
- Annotations used in the testing are very easy to understand ex: @BeforeMethod, @AfterMethod, @BeforeTest, @AfterTest
TestNG—Configuration and @Test Annotations:-
TestNG—TestNG Tab to See the Results—Failure:-
TestNG—TestNG Tab to See the Results—Success:-
I would like to thank my Logezy family to give me such kind of knowledge-sharing platform and encouraging me during the session to perform well.