list = driver.findElements(By.xpath(“//*[contains(text(),'” + text + “‘)]”));
Assert.assertTrue(“Text not found!”, list.size() > 0);
4. How to check whether the checkbox is selected or in unselected without using?
isSelected() method used to check whether the checkbox is selected or in unselected .
This method gives the Boolean value of true the checkbox is checked. It returns false, the checkbox is unchecked.
5. How to find whether the element is invisible or in hidden?
Use the below program for find whether the element is invisible or in hidden,
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class ElementStatus{
public static void main(String[] args) {
System.setProperty(“webdriver.chrome.driver”,
“C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe”);
WebDriver driver = new ChromeDriver();
String url =
“https://www.tutorialspoint.com/tutor_connect/index.php”;
// to verify if a static dropdown is selected with option isSelected()
boolean drpdwnStatus = driver.findElement(By.xpath(“//select[@name=’selType’]”))
.isSelected();
// to verify if an element is present on page with isDisplayed()
boolean editStatus = driver.findElement(By.xpath(“//input[@id=’txtSearchText’]”))
.isDisplayed();
// to verify if a button is enabled with isEnabled()
boolean butnStatus = driver.findElement(By.xpath(“//input[@id=’searchSubmit’]”))
.isEnabled();
System.out.println(“The button status is ” + butnStatus);
System.out.println
(“The dropdown selected status is” + drpdwnStatus);
System.out.println(“The edit box display status is ” + editStatus);
driver.close();
}
}
6. Difference between findElement and findElements
FindElement |
FindElements |
Throws NoSuchElementException if the element is not found |
Returns an empty list if no matching element is found |
Returns the first most web element if there are multiple web elements found with the same locator |
Returns a list of web elements |
This command is used to uniquely identify a web element within the web page. |
This command is used to uniquely identify the list of web elements within the web page. |
Need to Switch your career to automation:
7. How you will handle pop up windows?
Below are used to handle pop up windows,
Driver. getWindowHandles();
Driver. getWindowHandle();
8. What is testng?
TestNG means Test Next Generation is the testing framework. JUnit and NUnit are used to Testing, Its more powerful and easier from its new functionality. TestNG is designed in such a way that it covers all the categories of tests comprising unit, functional and integration.
9. How you are handling keyword driven and data-driven framework in your project?
Keyword driven framework :
The Keyword-Driven framework is a technique to externalize keywords or actions that are used in the script in a separate Object Repository which will give positive outcomes like increased code-reusability, reduced script maintenance, and higher portability.
Data driven framework :
Data Driven framework is focused on separating the test scripts logic and the test data from each other. Allows us to create test automation scripts by passing different sets of test data.
10. What is mean by hybrid framework?
Data-Driven and Keyword Driven frameworks both are mixed in hybrid frameworks. It is used in increased code reusability, higher portability, reduced cost of script maintenance, better code readability, etc.,
11. How can you upload file in webpage?
Use the below method for upload file in web page.
driver.findElement(By.xpath(“input field”)).sendKeys(“path of the file which u want to upload”);
12. How you will handle popup in web driver?
You need to use below code,
String parentWindowHandler = driver.getWindowHandle(); // Store your parent window
String subWindowHandler = null;
Set handles = driver.getWindowHandles(); // get all window handles
Iterator iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler); // switch to popup window
// Now you are in the popup window, perform necessary actions here
driver.switchTo().window(parentWindowHandler);
13. What framework your are using?
Types of frameworks
- Data Driven Automation Framework
- Method Driven Automation Framework
- Modular Automation Framework
- Keyword Driven Automation Framework
- Hybrid Automation Framework
You can explain which one you used in your project.
14. How can you handle pagination in Selenium Webdriver?
The syntax is List pagination =driver.findElemnts(By.xpath(“//div[@class=’nav-pages’]//a”));
- First of all, find the pagination elements by using findElemnts() and store as list of elements.
- To Get the pagination size.
- Check whether the pagination exist or not.
- If pagination exist, make a loop and click until last pagination size.
15. What is Selenium Grid?
Selenium Grid is the one of the important feature in selenium. I can allows to run multiple use cases in multiple machines.
Your local machine is running multiple applications, so you want to run your test cases in a remote machine. You need to configure the remote server so that the test cases can be executed there.
Free PDF : Get our updated Selenium Course Content pdf
16. What are all locators?
Types of locators:
- By CSS ID: find_element_by_id
- By CSS class name: find_element_by_class_name
- By name attribute: find_element_by_name
- By DOM structure or xpath: find_element_by_xpath
- By link text: find_element_by_link_text
- By partial link text: find_element_by_partial_link_text
- By HTML tag name: find_element_by_tag_name
17. Difference between findelements and findelement
findelements |
findelement |
It returns all the web elements which match with the locator. |
For matching with the locators, it returns the first web element |
if there are no matching web elements then returned NoSuchElementException |
if there are no matching web elements then returned empty list. |
Find element by XPath will only find one web element |
It will find a collection of elements whose match the locator strategy. |
18. How to handle Popup window?
The below two methods are used to handle popup window,
Driver. getWindowHandles()
Driver. getWindowHandle()
19. How to handle alert?
The following methods are useful to handle alerts in selenium:
driver.switchTo().alert().dismiss(); – Cancel button clicked in alert box
driver.switchTo().alert().accept(); – OK button alert
driver.switchTo().alert().getText(); – Capture the alert message
driver.switchTo().alert().sendKeys(“Text”); – Send data to the alert box
20. Difference between List and set
List |
Set |
It allows us to add the same or duplicate elements. |
It doesn’t allow us to add the same or duplicate elements. |
Implementation classes are LinkedList and ArrayList. |
Implementation classes are TreeSet, HashSet and LinkedHashSet. |
The insert order is followed in list |
It doesn’t maintain insertion |
21. Why we are using Set for Window Handle?
It is used to store the window id. Because unique window id are used to store. We can use set to store the window id.
22. Explain Map
Java HashMap class implements the Map interface by using a hashtable. It inherits the AbstractMap class and implements the Map interface.
23. Explain Agile methodology
Agile Test plan includes
- Testing Scope is the first step to create test plan.
- New functionalities which are being tested
- Level or Types of testing based on the features complexity
- Load and Performance Testing
- To consider the Infrastructure
- Mitigation or Risks Plan
- Understanding Resourcing
- Final thoughts of deliverables and milestones
24. How you are using Testng with Webdriver?
- To Create a new Java project in Eclipse to write your TestNG test case
- Add the library to your Java project
- Create packages for your project
- Write test case script
- Run the TestNG test case
- Run the execution
25. Difference in Testnng over Junit
TestNG |
Junit |
TestNG can run parallel tests. |
JUnit does not support to run parallel tests. |
In TestNG Dependency tests are present |
In Junit dependency tests are missed |
TestNG can run parallel tests. |
not support to run parallel tests. |
26. Draw the architecture diagram of your selenium Framework of your project
27. Waterfall model
Waterfall model is a sequential model that divides software development into predefined phases. Also each phase must be completed before the next phase can begin with no overlap between the any phases. This model in every phase is designed for performing specific activity during the Software development life cycle phase.
28. Defect life cycle
Defect life cycle, also called as Bug Life cycle is the journey of a defect cycle, which a defect goes through during its lifetime. It is different from company to company and also every project. It can be varies from software testing process and also depends upon the tools used.
29. SDLC life cycle
Software Development Life Cycle is known as SDLC, it is used to produce high-quality software that meets customer expectations. SDLC have a detailed planof your project which explains how to plan, build, and maintain specific application. >
It is the important part of project tracking and controlling. The another name of SDLC is Application Development life-cycle
30. Whether you are handling webtable in your project?
Webtable is used to organize same data on a web page. It is stored in row and column with group of elements.
You can explain whether you are handling webtable in your project.