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

Selenium Q&A Guide for Test Automation

The document contains a comprehensive list of questions related to Selenium, covering its benefits, limitations, WebDriver functionalities, locators, waits, and various testing frameworks like TestNG. It also includes practical problems that require scripting solutions for common automation tasks using Selenium. Overall, it serves as a guide for understanding and applying Selenium in test automation scenarios.

Uploaded by

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

Selenium Q&A Guide for Test Automation

The document contains a comprehensive list of questions related to Selenium, covering its benefits, limitations, WebDriver functionalities, locators, waits, and various testing frameworks like TestNG. It also includes practical problems that require scripting solutions for common automation tasks using Selenium. Overall, it serves as a guide for understanding and applying Selenium in test automation scenarios.

Uploaded by

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

Selenium Questions:

1. What are the Benefits of Selenium?


2. What are the Limitations of Selenium?
3. What is Selenium WebDriver?
4. What are the challenges or limitations of WebDriver?
5. What are the types of WebDriver APIs available in Selenium?
6. Define Locators
7. What are the different locators in Selenium?
8. What is dynamic locator?
9. What is XPATH?
10. What are the operators used in XPATH?
11. What is “AXES” in XPATH?
12. What are the relationships used in XPATH?
13. Explain the difference between single and double slash in XPATH?
14. Explain CSS Selector?
15. What is “Wait”? What is the purpose of adding waits?
16. What is Implicit Wait?
17. What is Explicit Wait?
18. Tell me few conditions that will be used in Explicit Wait?
19. What is the difference between Implicit & Explicit Wait?
20. What is Fluent Wait in Selenium?
21. What is Object Repository?
22. What is Page Factory?
23. What is Page Object Model?
24. What are the Advantages of POM?
25. What is TestNG? What are the features of TestNG?
26. List some of the functionality in TestNG which makes it more effective?
27. What are the different types of annotations used in TestNG?
28. How do you skip a test in TestNG?
29. How will you execute multiple tests of a pattern?
30. How will you execute tests belong to multiple classes at once?
31. What is the benefit of [Link]?
32. What is Alert? How will you handle Alert?
33. What are different types of Alerts?
34. How will you retrieve the message in an alert box ?
35. How do you handle Web-based Pop-ups in Selenium?
36. Mention 5 different exceptions you had in Selenium webdriver?
37. What is JavaScriptExecutor and in which cases JavaScriptExecutor will help in Selenium automation?
38. Tell some scenarios you could handle using "Java Script Executor" Interface?
39. Explain what is the difference between findElements() and findElement()?
40. Explain what is assertion in Selenium and what are the types of assertion?
41. What is the difference between verify and assert commands?
42. What is regular expression? How can you use regular expressions in Selenium?
43. Mention what is Listeners in Selenium WebDriver?
44. Mention what are the types of Listeners in TestNG?
45. What is the difference between [Link]() and [Link](“url”)?
46. What is the difference between getWindowhandles() and getwindowhandle() ?
47. Explain using Webdriver how you can perform double click?
48. How will you handle working with multiple windows in Selenium?
49. Explain how you can handle frames using Selenium?
50. How do you access Excel document?
51. How do you read test data from Excel document?
52. How do you write data in an Excel document?
53. How to capture Screenshot in Selenium WebDriver?
54. How do you create report in Selenium?

Selenium Problems:

1. Write a script to open a browser, launch an application (ex: facebook), identify a text box & key in a value,
identify a dropdown & pick a value from dropdown.
2. Write a script to launch an application in 3 different browsers (chrome, IE & Firefox) based on user’s choice &
ensure that you had to wait till all fields are loaded in the page
3. Write a script to open a browser, launch an application1, then move on to another application2, come to
application1 again and move on to application 2 again
4. Write a script to print the title & url of the web page and name of the tag & text from that tag
5. How can we handle Web-based Pop-ups or Alerts in Selenium?
6. How to select a value in a dropdown?
7. How to input text in the text box without calling the sendKeys()?
8. How to get a text of a web element?
9. How to get an attribute value using Selenium WebDriver?
10. How to submit a form using Selenium WebDriver?
11. How to press ENTER key on text box In Selenium WebDriver?
12. How to mouse hover on a web element using WebDriver?
13. How to handle hidden elements in Selenium WebDriver?
14. How to find more than one web element in the list?
15. How to read a JavaScript variable in Selenium WebDriver?
16. How To Scroll Web Page Down or UP using Selenium WebDriver?

Common questions

Powered by AI

Selenium handles alerts and web-based pop-ups using the Alert interface, which provides methods such as accept(), dismiss(), getText(), and sendKeys() to interact with alert boxes . The different types of alerts include simple alerts, confirmation alerts, and prompt alerts, each requiring different handling strategies. Understanding these types is essential for ensuring comprehensive automation coverage and robust interaction, as they can alter script flow depending on user interactions .

TestNG annotations, such as @BeforeMethod, @AfterMethod, @Test, @BeforeClass, and @AfterClass, improve the structure and efficiency of Selenium test suites by clearly defining test lifecycle and execution order . This eases the organization of tests, setting preconditions and postconditions, and configuring test dependencies. Annotations provide clear separation between setup, execution, and teardown phases, contributing to better test scalability and maintainability .

The JavaScriptExecutor interface allows execution of JavaScript code directly from Selenium WebDriver, extending its capabilities by interacting with elements that are not immediately accessible through standard methods . Its use is most appropriate in situations where elements are hidden, dynamic content needs forceful interaction, or when WebDriver's native support is limited, such as setting a value for a disabled text field or scrolling the page to a specific element .

Locators in Selenium WebDriver are essential for identifying elements on a webpage, which is crucial for interacting with web elements during testing. Efficient use of locators leads to robust and adaptable test scripts as elements may change due to UI updates . Types of locators include ID, Name, Class Name, Tag Name, Link Text, Partial Link Text, CSS Selectors, and XPATH, each offering different specificity and flexibility depending on the web element's attributes .

The Page Object Model (POM) enhances test automation by maintaining an abstraction layer between the test logic and page structure. It supports the principle of 'DRY' (Don't Repeat Yourself) by allowing a single place for locators and page-specific actions, which reduces code duplication. POM also promotes reuse and scalability, making test maintenance easier and more efficient—changes in the UI need updates only in the relevant page objects rather than across multiple test cases .

Explicit Wait is beneficial when dealing with specific conditions for elements that do not immediately become available. It allows setting conditions and polling intervals for a particular element, providing fine-grained control over synchronization issues . It is more effective than Implicit Wait in scenarios where complex conditions need to be checked, such as with elements loading after AJAX calls or when dealing with elements that dynamically change appearance and structure .

The primary difference between driver.get() and driver.navigate.to() in Selenium is that driver.get() waits for the page to load completely before script execution continues, whereas driver.navigate.to() can be used for more complex tasks like navigating back and forward, refreshing the page, and retaining browser history. Understanding this distinction is crucial for strategizing test scripts that require precise control over navigation and efficient page load handling .

XPATH is used in Selenium WebDriver to navigate through elements and attributes in an XML document, which is crucial for locating complex elements on web pages . Understanding XPATH operators like 'and', 'or', and 'mod', and axes such as 'ancestor', 'descendant', 'following', and 'preceding' allows for more precise and flexible locator strategies. These tools help locate elements based on their relationships rather than fixed attributes, which is vital for maintaining robust scripts when dealing with dynamic content .

The primary benefits of using Selenium WebDriver include its support for multiple browsers, operating systems, and programming languages, which provides flexibility . It also interacts directly with the browser, making it faster and more reliable for testing web applications . However, limitations include its inability to test mobile apps by default and the need for third-party integrations for advanced functionalities like image comparison. It also requires substantial technical skills to write and maintain scripts .

Capturing screenshots during test execution is crucial for visual validation, reporting, and debugging failed tests . In Selenium, capturing screenshots can be implemented using the TakesScreenshot interface, which provides methods like getScreenshotAs() for saving the visible portion of the webpage or entire page across different file formats. This feature ensures that issues are easily identified and communicated to development teams for quicker resolution .

You might also like