0% found this document useful (0 votes)
7 views6 pages

Selenium Interview Questions

The document provides an overview of Selenium, an automation testing tool for web applications, detailing its advantages, usage, and key concepts. It covers various commands, differences between methods, handling elements, and synchronization techniques. Additionally, it discusses TestNG, assertions, batch execution, parallel execution, and the Page Object Model (POM) principles.

Uploaded by

asildangi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Selenium Interview Questions

The document provides an overview of Selenium, an automation testing tool for web applications, detailing its advantages, usage, and key concepts. It covers various commands, differences between methods, handling elements, and synchronization techniques. Additionally, it discusses TestNG, assertions, batch execution, parallel execution, and the Page Object Model (POM) principles.

Uploaded by

asildangi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Selenium

1. What is Automation testing and when will we go for automation?


Testing the web application with help of a tool is known as automation testing.
Converting manual test cases into automation test script with help of the tool.
When the build is stable instead of doing regression testing, we are going for automation
testing.
a) To reduce the human effort in repetitive tasks.
b) To reduce the time in repetitive tasks.
c) To maintain accuracy in repetitive tasks.
d) To sustain in the market competition.

2. What is selenium? Advantages of Selenium?


It is an automation tool which is used to automate web-based application.
Advantages:
 It is an open source.
 It supports 14+ programming languages.
 It supports integration of 3rd party tools like cucumber, Auto IT, etc.
 It supports major operating systems (Windows, Mac, Linux).
 It supports major browsers.

3. How to launch empty browser?


WebDriver driver = new ChromeDriver () ;
Or
ChromeDriver driver = new ChromeDriver() ;

4. How to maximize the browser?


driver. manage (). window (). maximize ();

5. How to get width and height of the browser?


Dimension d=driver. manage(). window(). getSize();

6. Difference between close () and quit ()?


close() quit()
It is used to close the parent window It is used to close both the parent and child
windows
It will not stop the server It will stop the server
7. Difference between getWindowhandle() and getWindowhandles() ?

getWindowHandle() getWindowHandles()
It is used to fetch the session id of the It is used to fetch the session id of all the
parent window windows
Return type is String return type is Set<String>

8. Difference between findElement() and findElements() ?


findElement() findElements()
It is used to find one element at a time It is used to find multiple elements at a
time
Return type is WebElement Return type is List<WebElement>
It throws exception as It gives empty list
NoSuchElementFoundException

9. Difference between get () and navigate ()?


get() navigate ()
It is used to navigate to the web application Using this, we can navigate, refresh, move
forward and move backward
It will wait until the web page is loaded It will not wait for the webpage to load
Return type is void Return type is navigation type object

10. Difference between // and /?


/- Represents immediate child
//- Represents descendants

11. What are locators? Types of locators


Locators are used to identify elements present in the webpage.
Or
Locators are used to identify the location of the webelements in webpage.
There are 8 types of Locators
a) id ()
b) name ()
c) className ()
d) linkText ()
e) partialLinkText ()
f) tagName ()
g) cssSelector ()
h) xpath ()

12. Which is the fastest locator?


Id () is the fastest locator and given the 1st priority because it as unique value.
13. Difference between CSS selector and xpath?
CSS selector Xpath
We cannot use visible text We can use visible text using text ()
it is faster than xpath It is comparatively slow
It is unidirectional It is multi-directional

14. What is synchronisation?


The process of matching Selenium speed with application speed is called as
synchronisation.

15. What are the wait commands ?


a) Implicit wait
b) Explicit wait
c) Fluent wait

16. What is implicit wait?


Implicit wait will wait until webelements are loaded in the webpage.

17. Difference between implicit wait and explicit wait?


Implicit wait Explicit Wait
It works for findElement() and It works based on condition
findElements()
If no element found it returns TimeOutException
NoSuchElementFoundException or
EmptyList based on method used

18. How to take the screenshot of an entire web page?


TakesScreenshot ts = (TakesScreenshot) driver;
File temp = [Link]([Link]);
File dest= new File (“file path”);
[Link](temp, dest);

19. How to handle frames in Selenium ?


[Link]().frame(index or String id_name or webelement);

20. How to handle dropdown in Selenium ?


By using select class. we have to create object for the select class and pass the webelement
address as the argument.

21. How to perform Mouse and Keyboard actions in Selenium ?


By using Actions class. we have to create object for the Action class and pass the
WebDriver address as an argument
22. Which is the mandatory method to use in Actions class ?
perform () method

23. How to perform right click in Selenium?


contextClick () method

24. How to perform drag and drop in Selenium?


With the help of dragAndDrop() and dragAndDropBy() which is present in Actions class.
25. How to handle alert popup in Selenium?
Alert ref = driver. switchTo (). alert ();
we have 4 methods:
 [Link]()
 [Link]()
 [Link]()
 [Link]()

26. How to handle notification popup in Selenium ?


ChromeOptions setting =new ChromeOptions();
[Link](“--disable-notifications”);
[Link](“--incognito”);
WebDriver driver = new ChromeDriver(setting);

27. How to handle file upload popup ?


Use sendKeys(), we can pass the file path.

28. How to handle child browser popup ?


By using getWindowHandle(), getWindowHandles () and [Link]().window();

29. What is TestNg ?


It stands for Test Next Generation.
It is a unit testing tool for developers, but we has an automation engineer use testng for
Batch execution, Group execution, Parallel execution, Assertion, Report generation, Cross
Browser Testing.

30. Rules of TestNG?


 We should use @Test instead of main () method.
 We should use [Link]() instead of [Link]().
31. Annotations in TestNG?
@BeforeSuite
@AfterSuite
@BeforeTest
@AfterTest
@BeforeClass
@AfterClass
@BeforeMethod
@AfterMethod
@Test
@DataProvider
@Parameters
@Listeners

32. What is Assertion?


It is inbuilt libraries or functions which is used to validate critical checkpoints of the test
cases.
We go for assertion to reduce the lines of code.
There are two types of assertion
a) Hard Assert
b) Soft Assert

33. Difference between Hard assert and Soft assert ?


Hard Assert Soft Assert
In case of failure, test case will be In case of failure, test case will not
terminated abruptly terminate abruptly

No need to call any method to show We need to call assertAll() to show


assertion error assertion failure

All the methods are static methods All the methods are non-static methods

34. How to perform Batch execution?


Executing all the classes together via [Link] file is called batch execution.
Create a suite file and run it.

35. How to perform Parallel execution?


In Test level give parallel = “classes” or “methods” or “true”
36. What is POM and its rules?
It stands Page Object Model , it is used to store web elements
We go for Pom to avoid StaleElementReferenceException as well as to avoid Hardcoding of
Locators
Rules: -
a) Number of web pages should be equal to number of POM classes
b) Number of web elements should be equal to Number of web element variables
c) All elements should be made private.
d) All elements should have getters.
e) Elements can be initialized using page factory class.

You might also like