Selenium Training (advanced)
· Selenium Integrated Development Environment (IDE)
· Selenium Remote Control (RC)
· WebDriver
· Selenium Grid
-------------------------------------------------------------------------------------------------------------------------
Uplatz offers this advance course on Selenium automated web testing. This expert-level Selenium training is focused on advanced features of Selenium and is ideally suited for experienced software testers. Our training and certification program gives you a solid understanding of the key topics covered on the Agile Testing Alliance’s (CA-CPT Certification). In addition to boosting your income potential, getting certified in Automation Testing with Selenium, demonstrates your knowledge of the skills necessary to be an effective Selenium Automation Tester. The certification validates your ability to produce reliable, high-quality results with increased efficiency and consistency.
-------------------------------------------------------------------------------------------------------------------------
Selenium Training (advanced)
Lesson 1: JUnit and Data Driven Framework
· Building the Test Base Class
· Using Annotations of JUnit
· Reading XPATHS, Configuration from properties file
· Initialize the WebDriver
· Building the Test Base Class
· Implementing WebDriver Implicit Wait
· Implementing tests and batch running them
· Repeating a test with different Data
· Building utility functions
· Parameterizing tests using XL Files
· Controlling Execution order from XL Files
· Assertions and Reporting Errors / ErrorCollector
· Storing Screenshots of errors
· Running the framework through ANT
· Generating the HTML reports
· Emailing test reports
· Creating a BAT file for project execution
JUnit and Hybrid (Keyword + Functional Decomposition) Framework
· Overview of Hybrid (Keyword + Data Driven) Framework
· Building XLS File Having Test Cases and Keywords
· Building XLS File Having Test Data
· Building Base class
· Reading XPATHS, Configuration from properties file
· Implementing ImplicitWait
· Implementing the keywords using the reflection API
· Implementing Tests
· Assertions and Reporting Errors
· Parameterizing tests using DataProvider and XL Files
· Repeating a test with different Data
· Running the framework through ANT
· Generating the reports
· Emailing test reports
· Creating a BAT file for project execution
TestNg, Functional Decomposition & PageObject Model Framework
· Overview of Data driven framework
· Building the Test Base Class
· Using Annotations of TestNg
· Reading XPATHS, Configuration from properties file
· Initialize the WebDriver
· Implementing WebDriver Implicit Wait
· Implementing tests and batch running them
· Repeating a test with different Data
· Implement logging with Log4J API
· Building utility functions
· Parameterizing tests using XL Files
· Controlling Execution order from XL Files
· Assertions and Reporting Errors
· Storing Screenshots of errors
· Running the framework through ANT
· Generating the XSLT reports
· Creating a BAT file for project execution
· Emailing Test Reports
TestNg and Hybrid (Keyword + Data Driven) Framework
· Overview of Hybrid Framework
· Building XLS File Having Test Cases and Keywords
· Building XLS File Having Test Data
· Building Base class
· Reading XPATHS, Configuration from properties file
· Implementing WebDriverWait
· Implementing the keywords using the reflection API
· Implementing Tests
· Assertions and Reporting Errors
· Parameterizing tests using DataProvider and XL Files
· Repeating a test with different Data
· Running the framework through ANT
· Generating the reports
· Emailing test reports
· Creating a BAT file for project execution
-------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Selenium Interview Questions
----------------------------------------------------------------------------------------------------1) What is Selenium and what is composed of?
Selenium is a suite of tools for automated web testing. It is composed of
- Selenium IDE (Integrated Development Environment) : It is a tool for recording and playing back. It is a firefox plugin
- WebDriver and RC: It provide the APIs for a variety of languages like Java, .NET, PHP, etc. With most of the browsers Webdriver and RC works.
- Grid: With the help of Grid you can distribute tests on multiple machines so that test can be run parallel which helps in cutting down the time required for running in browser test suites
2) What is Selenium 2.0?
Web Testing tools Selenium RC and WebDriver are consolidated in single tool in Selenium 2.0
3) Could you state the limitations of Selenium?
- Although Selenium has an active community support, no vendor support is available
- No built-in report generation. Third-party tools like JUnit and TestNG need to be used
- Not able to offer testing for barcode and captcha readers
- Requires good programming language knowledge
- Supports testing of only web-based applications. Hence, doesn’t provide support for testing mobile applications
4) What are the different types of locators in Selenium?
A locator is a kind of address that offers a unique way of identifying a web element on the webpage. Selenium has a range of locators to identify different elements of a webpage, namely:
- ClassName
- CSS Selector
- DOM
- ID
- LinkText
- Name
- PartialLinkText
- TagName
- XPath
5) Can you explain the difference between assert and verify commands in Selenium?
Both assert and verify commands are responsible for checking whether the given condition is true or false. However, the main distinction between the two lies what each of them does after the condition checking is complete.
If the condition comes out to be false in the case of a verify command, then the execution stops and no further tests will be executed. However, if the condition is true then the program control will continue executing the next test step.
Verify command, on the other hand, does not care about the result of the condition checking. Whether it is true or false, the program execution continues and all the test steps will be completed.
6) What do you understand by XPath in Selenium? Can you tell the difference between “/” and “//” in XPath?
XPath is a type of locator in Selenium that is used to locate a web element based on its XML path. XML denotes Extensible Markup Language, which is used for storing, organizing, and transporting arbitrary data. Much like HTML tags, XML stores data in a key-value pair.
Since HTML and XML both are markup languages, XPath can be used for locating HTML elements on a webpage. The underlying principle of XPath is traversing between several elements across the entire webpage and allowing them to find an element with the reference of some other element.
The single slash i.e. ‘/’ is used to create XPath with the absolute path, while the double slash i.e. ‘//’ is used for creating XPath with the relative path.
In the absolute path, the created XPath will start selection from the document node or the start node. However, in the relative path, the created XPath can start selection from anywhere within the entire web document.
7) How will you launch the browser using WebDriver?
The syntax used for launching Google Chrome, Mozilla Firefox, and Internet Explorer using WebDriver is respectively,
- WebDriver driver = new FirefoxDriver();
- WebDriver driver = new ChromeDriver();
- WebDriver driver = new InternetExplorerDriver();
8) What do you mean by Same Origin Policy? How to handle it?
An Origin is a sequential combination of host, scheme, and port of the URL. The issue of the same-origin policy restricts accessing the DOM of a document from an origin that is different from the one that a user is trying to access the document.
The Selenium Core isn’t allowed to access the elements from an origin that is different from where it was launched. Selenium Remote Control was introduced in order to handle the problem of Same Origin Policy.
9) Do you know how to get a text of a web element using Selenium?
In order to retrieve the inner text of a specified web element, Selenium offers the get command. It returns a string value and doesn’t require any parameters. Get command is one of the most widely used commands for verifying errors, labels, messages, etc. displayed on webpages. The general syntax for the get command is:
String Text = driver.findElement(By.id(“Text”)).getText();
10) Why should Selenium be selected as a test tool?
Selenium
1. is a free and open source
2. have a large user base and helping communities
3. have cross Browser compatibility (Firefox, Chrome, Internet Explorer, Safari etc.)
4. have great platform compatibility (Windows, Mac OS, Linux etc.)
5. supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
6. has fresh and regular repository developments
7. supports distributed testing
11) What are the testing types that can be supported by Selenium?
Selenium supports the following types of testing:
1. Functional Testing
2. Regression Testing
12) When should I use Selenium IDE?
Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature makes it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is an ideal tool for a naïve user.
13) What is Selenese?
Selenese is the language which is used to write test scripts in Selenium IDE.
14) What is the difference between assert and verify commands?
Assert: Assert command checks whether the given condition is true or false. Let’s say we assert whether the given element is present on the web page or not. If the condition is true then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed.
Verify: Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn’t halt i.e. any failure during verification would not stop the execution and all the test steps would be executed.
15) When should I use Selenium Grid?
Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution, testing under different environments and saving execution time remarkably.
16) What do we mean by Selenium 1 and Selenium 2?
Selenium RC and WebDriver, in a combination, are popularly known as Selenium 2. Selenium RC alone is also referred to as Selenium 1.
17) Which is the latest Selenium tool?
WebDriver
18) What are the different types of Drivers available in WebDriver?
The different drivers available in WebDriver are:
- FirefoxDriver
- InternetExplorerDriver
- ChromeDriver
- SafariDriver
- OperaDriver
- AndroidDriver
- IPhoneDriver
- HtmlUnitDriver
19) What are the different types of waits available in WebDriver?
There are two types of waits available in WebDriver:
1. Implicit Wait
2. Explicit Wait
20) How to type in a textbox using Selenium?
The user can use sendKeys(“String to be entered”) to enter the string in the textbox.
21) How to select value in a dropdown?
The value in the dropdown can be selected using WebDriver’s Select class.
22) How to click on a hyper link using linkText?
driver.findElement(By.linkText(“Google”)).click();
The command finds the element using link text and then click on that element and thus the user would be re-directed to the corresponding page.
The above-mentioned link can also be accessed by using the following command.
driver.findElement(By.partialLinkText(“Goo”)).click();
The above command finds the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.
23) What is the difference between driver.close() and driver.quit command?
close(): WebDriver’s close() method closes the web browser window that the user is currently working on or we can also say the window that is being currently accessed by the WebDriver. The command neither requires any parameter nor does it return any value.
quit(): Unlike close() method, quit() method closes down all the windows that the program has opened. Same as close() method, the command neither requires any parameter nor does is return any value.
24) Can Selenium handle windows based pop up?
Selenium is an automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Selenium.
25) How can we handle web-based pop-up?
WebDriver offers the users a very efficient way to handle these pop-ups using Alert interface. There are the four methods that we would be using along with the Alert interface.
- void dismiss() – The dismiss() method clicks on the “Cancel” button as soon as the pop-up window appears.
- void accept() – The accept() method clicks on the “Ok” button as soon as the pop-up window appears.
- String getText() – The getText() method returns the text displayed on the alert box.
- void sendKeys(String stringToSend) – The sendKeys() method enters the specified string pattern into the alert box.
26) How can we handle windows based pop up?
Selenium is an automation testing tool which supports only web application testing, that means, it doesn’t support testing of windows based applications. However Selenium alone can’t help the situation but along with some third-party intervention, this problem can be overcome. There are several third-party tools available for handling window based pop-ups along with the selenium like AutoIT, Robot class etc.
27) How to assert the title of the web page?
assertTrue(“The title of the window is incorrect.”,driver.getTitle().equals(“Title of the page”));
28) How to mouse hover on a web element using WebDriver?
WebDriver offers a wide range of interaction utilities that the user can exploit to automate mouse and keyboard events. Action Interface is one such utility which simulates the single user interactions.
Thus, In the following scenario, we have used Action Interface to mouse hover on a drop down which then opens a list of options.
29) What is Junit?
Junit is a unit testing framework introduced by Apache. Junit is based on Java.
30) What are Junit annotations?
Following are the JUnit Annotations:
- @Test: Annotation lets the system know that the method annotated as @Test is a test method. There can be multiple test methods in a single test script.
- @Before: Method annotated as @Before lets the system know that this method shall be executed every time before each of the test methods.
- @After: Method annotated as @After lets the system know that this method shall be executed every time after each of the test method.
- @BeforeClass: Method annotated as @BeforeClass lets the system know that this method shall be executed once before any of the test methods.
- @AfterClass: Method annotated as @AfterClass lets the system know that this method shall be executed once after any of the test methods.
- @Ignore: Method annotated as @Ignore lets the system know that this method shall not be executed.
31) What is TestNG and how is it better than Junit?
TestNG is an advanced framework designed in a way to leverage the benefits by both the developers and testers. With the commencement of the frameworks, JUnit gained enormous popularity across the Java applications, Java developers and Java testers with remarkably increasing the code quality. Despite being easy to use and straightforward, JUnit has its own limitations which give rise to the need of bringing TestNG into the picture. TestNG is an open source framework which is distributed under the Apache Software License and is readily available for download.
32) What is a framework?
The framework is a constructive blend of various guidelines, coding standards, concepts, processes, practices, project hierarchies, modularity, reporting mechanism, test data injections etc. to pillar automation testing.
33) What are the advantages of the Automation framework?
The advantage of Test Automation framework
• Reusability of code