Automation testing uses automation tools to write and execute test cases, no manual involvement is necessary for executing an automated test suite. Testers prefer automation tools to write test scripts and test cases and then group into test suites.
PLAN -> CODE -> BUILD -> TEST -> RELEASE -> DEPLOY -> OPERATE -> MONITOR
Automation testing enables the use of specialized tools to automate the execution of manually designed test cases without any human intervention. Automation testing tools can access the test data, controls the execution of tests and compares the actual result against the expected result. Consequently, generating detailed test reports of the system under test.
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 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.
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.
What are the different ways of locating a web element in Selenium?
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:
List out some of the Automation tools which could be integrated with Selenium to achieve continuous testing.
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.
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".
Explain the difference between assert and verify commands?
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.
What is the difference between "type" and "typeAndWait" command?
"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.
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.
Selenium Grid facilitates you to distribute your tests on multiple machines and all of them at the same time. So, you can execute tests on Internet Explorer on Windows and Safari on Mac machine using the same text script. It reduces the time of test execution and provides quick feedback.
Write a code snippet to launch Chrome browser in WebDriver.
public class ChromeBrowserLaunchDemo { public static void main(String[] args) { //Creating a driver object referencing WebDriver interface WebDriver driver; //Setting the webdriver.chrome.driver property to its executable's location System.setProperty("webdriver.chrome.driver", "/lib/chromeDriver/chromedriver.exe"); //Instantiating driver object driver = newChromeDriver(); //Using get() method to open a webpage driver.get("http://javatpoint.com"); //Closing the browser driver.quit(); } }
Write a code snippet to launch Internet Explorer browser in WebDriver.
public class IEBrowserLaunchDemo { public static void main(String[] args) { //Creating a driver object referencing WebDriver interface WebDriver driver; //Setting the webdriver.ie.driver property to its executable's location System.setProperty("webdriver.ie.driver", "/lib/IEDriverServer/IEDriverServer.exe"); //Instantiating driver object driver = newInternetExplorerDriver(); //Using get() method to open a webpage driver.get("http://javatpoint.com"); //Closing the browser driver.quit(); } }
What is POM (Page Object Model)? What are its advantages?
Page Object Model is a design pattern for creating an Object directory for web UI elements. Each web page is required to have its page class. The page class is responsible for finding the WebElements in web pages and then perform operations on WebElements.
The benefits of using POM are as follows:
It facilitates with separate operations and flows in the UI from Verification - improves code readability
Multiple tests can use the same Object Repository because the Object Repository is independent of Test Cases.
How can you find if an element is displayed on the screen?
WebDriver allows user to check the visibility of the web elements. These web elements can be buttons, radio buttons, drop, checkboxes, boxes, labels etc. which are used with the following methods.