71. How to select value in a drop-down?
The value in the drop down can be selected using WebDriver’s Select class.
Select selectByValue = new Select(driver.findElement(By.id(“SelectID_One”)));
Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));
Select selectByIndex = new Select(driver.findElement(By.id(“SelectID_Three”)));
72. What are the different types of navigation commands?
Following are the navigation commands:
navigate().back() – The above command requires no parameters and takes back the user to the previous webpage in the web browser’s history.
navigate().forward() – This command lets the user to navigate to the next web page with reference to the browser’s history.
navigate().refresh() – This command lets the user to refresh the current web page there by reloading all the web elements.
navigate().to() – This command lets the user to launch a new web browser window and navigate to the specified URL.
73. How to click on a hyper link using linkText?
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.
The above command find 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.
74. How to handle frame in WebDriver?
An inline frame acronym as iframe is used to insert another document with in the current HTML document or simply a web page into a web page by enabling nesting.
Select iframe by id
driver.switchTo().frame(“ID of the frame“);
Locating iframe using tagName
Locating iframe using index
frame(Name of Frame)
driver.switchTo().frame(“name of the frame”);
Select Parent Window
75. When do we use findElement() and findElements()?
findElement(): findElement() is used to find the first element in the current web page matching to the specified locator value. Take a note that only first matching element would be fetched.
WebElement element = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));
findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements.
List elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));
76. 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 an 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.
TestNG with WebDriver provides an efficient and effective test result format that can, in turn, be shared with the stakeholders to have a glimpse on the product’s/application’s health thereby eliminating the drawback of WebDriver’s incapability to generate test reports. TestNG has an inbuilt exception handling mechanism which lets the program to run without terminating unexpectedly.
There are various advantages that make TestNG superior to JUnit. Some of them are:
• Added advance and easy annotations
• Execution patterns can set
• Concurrent execution of test scripts
• Test case dependencies can be set
77. What is a framework?
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.
78. What are the advantages of Automation framework?
Advantage of Test Automation framework
• Reusability of code
• Maximum coverage
• Recovery scenario
• Low cost maintenance
• Minimal manual intervention
• Easy Reporting
79. What are the different types of frameworks?
Below are the different types of frameworks:
Module Based Testing Framework: The framework divides the entire “Application Under Test” into number of logical and isolated modules. For each module, we create a separate and independent test script. Thus, when these test scripts taken together builds a larger test script representing more than one module.
Library Architecture Testing Framework: The basic fundamental behind the framework is to determine the common steps and group them into functions under a library and call those functions in the test scripts whenever required.
Data Driven Testing Framework: Data Driven Testing Framework helps the user segregate the test script logic and the test data from each other. It lets the user store the test data into an external database. The data is conventionally stored in “Key-Value” pairs. Thus, the key can be used to access and populate the data within the test scripts.
Keyword Driven Testing Framework: The Keyword driven testing framework is an extension to Data driven Testing Framework in a sense that it not only segregates the test data from the scripts, it also keeps the certain set of code belonging to the test script into an external data file.
Hybrid Testing Framework: Hybrid Testing Framework is a combination of more than one above mentioned frameworks. The best thing about such a setup is that it leverages the benefits of all kinds of associated frameworks.
Behaviour Driven Development Framework: Behaviour Driven Development framework allows automation of functional validations in easily readable and understandable format to Business Analysts, Developers, Testers, etc.
80. Can WebDriver test Mobile applications?
WebDriver cannot test Mobile applications. WebDriver is a web-based testing tool, therefore applications on the mobile browsers can be tested.