16 Feb
16Feb

TB-1: How to identify a WebElement in a WebPage?

By using locators such as ID, Name, Class, LinkText, xPath, CSS etc

Example: driver.findElement(By.id("username"));In above example, 
"id" is a locator of an WebElement and "username" is a value of the WebElement on a WebPage.** WebElement locators we can find by using HTML DOM Structure. To go to WebElement in a HTML DOM Structure
--> Right click on the WebElement and click on 'Inspect' option in context menu.

TB-2: How to create an object for ChromeDriver?

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ToLaunchChromeBrowser {
     public static void main(String[] args) {
         // Below code will launch the Chrome Browser & driver is an object for browser instance
          System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
          WebDriver driver = new ChromeDriver(); //Launches the Chrome Browser
     }
}

TB-3: What is the difference between Absolute path and Relative Path?

Absolute Path:
This path starts from the root node and ends with the desired elements node.It starts with a single slash (/)

Example: /html/body/div/td/input

Relative Path:

This path starts from any node in between and to the desired elements node. It starts with a double slash (//)

Example: //input[@id=name]

TB-4: What is the difference between Assert and Verify statements in Selenium?

Assert:
We can check whether an element is on the page or not. The test fails and gets terminated whenever there is a fail in the check. That is the program control flow stops.

Verify:
It’s only to specify whether the given condition is true or false. The program control flow does not stop due to this.

Overall, the Verify statement does not halt the program execution whereas the Assert statement does halt the execution.

TB-5: What is the difference between findElement() and findElements()?

findElement() : It uses the given locating mechanism to find the first element within the current page and return a single web element.


findElements() : It also uses the given locating mechanism to find all the elements within the current page and return the list of all web elements.

TB-6: What are the verification points that are available in Selenium?

Selenium IDE: Verify and Assert commands

Selenium Web Driver: This does not have any built-in features for verification and always depends on our coding style. Some examples can be like checking the page title, checking for certain text in the page, checking for a certain element like textbox, dropdown, field etc.,

TB-7: Explain Implicit wait, Explicit wait and Fluent wait?

Implicit wait: We can set the timeout for a specific amount of time for all the successive web elements. In this specified time, the web driver searches for all the web elements before throwing the NoSuchElement Exception.

Explicit wait: We can tell the Web Driver to wait for certain conditions before throwing the ElemntNotVisible Exception.

Fluent wait: It’s a slight extension for the explicit wait. Apart from waiting for certain conditions to be met, we can also set the frequency with which we check the condition before throwing the ElementNotVisible Exception.

TB-8: What is the major difference between driver.close() and driver.quit()?

driver.close(): It’s a command by which the current window can be closed. For example, if we have multiple browser windows open then,  by using this command we can close the window with which the focus is.
driver.quit(): This command closes all the browser windows which are open. For example, if we have multiple browser windows open then, this command can close all the windows at once.

TB-9: What is the difference between the getwindowhandle() and getwindowhandles()?

getwindowhandles(): This is used to get the address of all the open browsers and returns the data type of Set<String>.

getwindowhandle(): This is used to get the address of the current browser window where it’s focused on and returns the data type of String.

TB-10: What are the different kinds of frameworks?

Data-driven framework: The test data of this kind is generated from external files like excel, CSV, XML, etc. The data relating to the test cases rely outside on the input and verification values maintained using the variables.

Keyword-driven framework: The data tables and the keywords are developed independently of the automation test cases. In this framework, the functionality of the test scenarios is documented in the table step by step.

Module-based testing framework: Isolated and Logical modules are made out of the application that is under test. Independent test scripts are written for each module. These scripts are then clubbed together as a whole.

Behavior driven testing framework: The test scripts are written in such a way that the automation is done on the functionality or features to ensure the readability, understanding, and reliability to either the business experts or developers, or other testers.

Hybrid testing framework: The combination of more than one of the above-mentioned frameworks by leveraging the benefits of each is called a Hybrid testing framework.

TB-11: What is an Object Repository and Explain how we can create the Object Repository in Selenium?

The collection of web elements that belongs to the application under test along with their locator values. This is often referred to as Object Repository. The only thing is the locators are stored in a centralized location than hard coding them in the test scripts.

While coming to Selenium, the objects can be stored in Excel also and can be used to populate them in the script whenever required.

TB-12: Can Selenium handle windows-based pop-up?

As we already know that Selenium is an automation testing tool that can work with only web applications. Therefore, the pop-up in windows cannot be handled by Selenium. But, by integrating with the third-party tools we can overcome this problem.

TB-13: What are the different types of Annotations used in Selenium?

Syntactic metadata can be added to the Java source code which is known as annotations. They can be added on variables, parameters, packages, classes etc., Some of them which are used in Selenium include,
@Before, @Test, @After

TB-14: What is the difference between setSpeed() and sleep() methods?

These methods will delay the speed of the execution.

Thread.sleep(): The current thread will stop for a specified period of time. It only waits once when the command is given. It takes only a single argument that is Integer format.

set sleep(): This command will stop the execution for every selenium command. This command is used only for demonstration purposes and also for a slow web application.

TB-15: How can you store a value in a text box?

A command which can store the value from the text box using a web driver.

For example, 

driver.findElement(By.id(“your Textbox”)).sendKeys(“your keyword”);

TB-16: How can you debug the tests in the Selenium IDE?

We need to first insert the breakpoints where we need to debug and execute the test step by step. Later, Run the test case. 

After this, the execution stops at the point where the breakpoint is kept. You can click on the Run button to continue the execution of all the commands sequentially.

TB-17: How can you handle working with multiple windows in Selenium?

selectWindow() command in Selenium can be used to switch among the working windows. The distinguishing factor among all the windows is the title of the window.

TB-18: How can the message in the alert box be retrieved?

storeAlert() command can be used to retrieve the message from the alert pop-up and store it in a variable.

TB-19: When do you use AutoIT?

As we already know that Selenium is used only to automate web applications. But if we want to handle or manage or maintain the GUI, HTML pop-ups then, we need the use of AutoIT.

TB-20: Can you automate CAPTCHA?

The answer is No. We cannot automate CAPTCHA in Selenium. The concept of CAPTCHA is to ensure that the bots or automated test scripts should not have access to sensitive information, and that is why we cannot automate it. 

The captcha should be manually typed in order to continue the flow of execution of the test suite.

TB-21: How do we launch different browsers in Selenium?

A driver instance should be created for a particular browser which we need to work upon.

WebDriver driver = new FireFoxDriver();

WebDriver driver = new ChromeDriver();

Here, the WebDriver is the interface where the Firefox, chrome and all other browser driver implementations are made.

TB-22: What is Locator and How do you locate an element in Selenium?

The elements of the web page are found and matched using locators to interact with. There are different kinds of locators to identify different types of elements on the web page. 

They are as follows,

  • ID
  • Name
  • Class
  • Partial Link
  • XPath
  • CSS Selector
  • Link Text

TB-23: Explain different types of Exceptions in Selenium Web driver?

The Exceptions in the Selenium web driver are also similar to the exceptions in any other programming language like Java, C#, etc., Some of the most common exceptions are as follows,

TimeOutException: This exception can be thrown when a particular operation cannot be completed in a specified or stipulated time.

NoSuchElementException: When an element in the given set of attributes is not present on the web page then, this exception can be thrown.

ElementNotVisibleException: There can be cases where a particular element can be present in the DOM (Document Object Model) but not visible on the web page. In such cases, this exception can be thrown.

StaleElementException: When an element is either deleted or no longer present in the DOM then, this exception can be thrown. We generally face this exception when the element we are interacting with is either destroyed or recreated again.

TB-24: Which API is used for database testing in the Selenium web driver?

JDBC (Java Database connectivity) is used for database testing in Selenium. This allows us to write the SQL (Structured Query Language) queries and execute them.

TB-25: Which implementation of the web driver is the fastest?

The web driver implementation HTML Unit Driver is the fastest of all. This is because this driver does not execute the tests in the browser but rather, executes only the plain HTTP which is quick faster as expected.

TB-26: What can Selenium be used for?

Selenium is used for automation testing on various web browsers such as  Chrome, Mozilla, Firefox, Safari, and IE. 

With the help of a selenium web driver, one can easily automate browser testing.

TB-27: Which language is best for selenium?

Python and Ruby are the best binding languages for selenium as software may automatically load the driver, if it is present in the same folder as your system or in the python path.

Others: Java: Java remains the most popular programming language for test automation but not good as it is not a scripting language.

JavaScript: JavaScript is used for test automation by 35% of our users writing their tests in this language.

Comments
* The email will not be published on the website.