{"id":27961,"date":"2022-02-25T11:38:31","date_gmt":"2022-02-25T11:38:31","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=27961"},"modified":"2026-02-25T11:41:24","modified_gmt":"2026-02-25T11:41:24","slug":"qa-automation-%f0%9d%97%96%f0%9d%97%bc%f0%9d%97%bf%f0%9d%97%b2-%f0%9d%97%9d%f0%9d%97%ae%f0%9d%98%83%f0%9d%97%ae-%f0%9d%97%a6%f0%9d%97%b2%f0%9d%97%b9%f0%9d%97%b2%f0%9d%97%bb%f0%9d%97%b6%f0%9d%98%82","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/qa-automation-%f0%9d%97%96%f0%9d%97%bc%f0%9d%97%bf%f0%9d%97%b2-%f0%9d%97%9d%f0%9d%97%ae%f0%9d%98%83%f0%9d%97%ae-%f0%9d%97%a6%f0%9d%97%b2%f0%9d%97%b9%f0%9d%97%b2%f0%9d%97%bb%f0%9d%97%b6%f0%9d%98%82\/","title":{"rendered":"QA Automation \ud835\uddd6\ud835\uddfc\ud835\uddff\ud835\uddf2 \ud835\udddd\ud835\uddee\ud835\ude03\ud835\uddee &#038; \ud835\udde6\ud835\uddf2\ud835\uddf9\ud835\uddf2\ud835\uddfb\ud835\uddf6\ud835\ude02\ud835\uddfa \ud835\udde7\ud835\uddf2\ud835\uddf0\ud835\uddf5\ud835\uddfb\ud835\uddf6\ud835\uddf0\ud835\uddee\ud835\uddf9 Interview Questions"},"content":{"rendered":"<p>&nbsp;<\/p>\n<h1>QA Automation \u2013 Core Java &amp; Selenium \ud835\udde7\ud835\uddf2\ud835\uddf0\ud835\uddf5\ud835\uddfb\ud835\uddf6\ud835\uddf0\ud835\uddee\ud835\uddf9 Interview Questions<\/h1>\n<hr \/>\n<h2>1\ufe0f\u20e3 What are the differences between <code class=\"\" data-line=\"\">findElement()<\/code> and <code class=\"\" data-line=\"\">findElements()<\/code>?<\/h2>\n<h3>Sample Answer:<\/h3>\n<ul>\n<li><strong>findElement()<\/strong> returns a single WebElement.<\/li>\n<li>If the element is not found, it throws <strong>NoSuchElementException<\/strong>.<\/li>\n<li><strong>findElements()<\/strong> returns a List&lt;WebElement&gt;.<\/li>\n<li>If no elements are found, it returns an <strong>empty list<\/strong> (does not throw exception).<\/li>\n<li>findElement() is used when exactly one element is expected.<\/li>\n<li>findElements() is used for multiple elements like dropdown options, lists, tables.<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<pre>WebElement loginBtn = driver.findElement(By.id(\"login\"));\r\nList&lt;WebElement&gt; links = driver.findElements(By.tagName(\"a\"));\r\n<\/pre>\n<hr \/>\n<h2>2\ufe0f\u20e3 How do you handle dynamic web elements in Selenium?<\/h2>\n<h3>Sample Answer:<\/h3>\n<p>I handle dynamic elements using:<\/p>\n<ul>\n<li><strong>Dynamic XPath:<\/strong> using contains(), starts-with()<\/li>\n<li><strong>CSS Selectors<\/strong> with partial attributes<\/li>\n<li><strong>Explicit Waits<\/strong> for dynamic loading<\/li>\n<li>Handling <strong>StaleElementReferenceException<\/strong> with re-locating element<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<pre>driver.findElement(By.xpath(\"\/\/input[contains(@id,'user')]\"));\r\n<\/pre>\n<hr \/>\n<h2>3\ufe0f\u20e3 Explain different types of waits used in Selenium.<\/h2>\n<h3>Sample Answer:<\/h3>\n<ul>\n<li><strong>Implicit Wait<\/strong> \u2013 Applied globally, waits for elements to be present.<\/li>\n<li><strong>Explicit Wait (WebDriverWait)<\/strong> \u2013 Waits for a specific condition.<\/li>\n<li><strong>Fluent Wait<\/strong> \u2013 Custom polling time, ignores specific exceptions.<\/li>\n<\/ul>\n<p><strong>Example of Explicit Wait:<\/strong><\/p>\n<pre>WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));\r\nwait.until(ExpectedConditions.visibilityOfElementLocated(By.id(\"submit\")));\r\n<\/pre>\n<hr \/>\n<h2>4\ufe0f\u20e3 What\u2019s the difference between XPath and CSS Selector?<\/h2>\n<h3>Sample Answer:<\/h3>\n<table border=\"1\" cellpadding=\"8\">\n<tbody>\n<tr>\n<th>XPath<\/th>\n<th>CSS Selector<\/th>\n<\/tr>\n<tr>\n<td>Can traverse forward &amp; backward<\/td>\n<td>Only forward traversal<\/td>\n<\/tr>\n<tr>\n<td>Supports contains(), text()<\/td>\n<td>No text() support<\/td>\n<\/tr>\n<tr>\n<td>Slower compared to CSS<\/td>\n<td>Generally faster<\/td>\n<\/tr>\n<tr>\n<td>More powerful for complex DOM<\/td>\n<td>Cleaner &amp; shorter syntax<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>5\ufe0f\u20e3 How do you handle multiple windows\/tabs in Selenium?<\/h2>\n<h3>Sample Answer:<\/h3>\n<p>I use <code class=\"\" data-line=\"\">getWindowHandles()<\/code> to get all window IDs and switch using <code class=\"\" data-line=\"\">switchTo().window()<\/code>.<\/p>\n<pre>String parent = driver.getWindowHandle();\r\nSet&lt;String&gt; windows = driver.getWindowHandles();\r\n\r\nfor(String window : windows){\r\n    if(!window.equals(parent)){\r\n        driver.switchTo().window(window);\r\n    }\r\n}\r\n<\/pre>\n<hr \/>\n<h2>6\ufe0f\u20e3 How do you design a Page Object Model (POM) framework?<\/h2>\n<h3>Sample Answer:<\/h3>\n<p>In POM framework:<\/p>\n<ul>\n<li>Each page is represented as a separate class.<\/li>\n<li>Web elements are declared using <code class=\"\" data-line=\"\">@FindBy<\/code>.<\/li>\n<li>Page methods contain business logic.<\/li>\n<li>Test classes call page methods.<\/li>\n<li>Common utilities like BaseTest, DriverFactory are separated.<\/li>\n<\/ul>\n<p><strong>Advantages:<\/strong><\/p>\n<ul>\n<li>Code reusability<\/li>\n<li>Maintainability<\/li>\n<li>Separation of concerns<\/li>\n<\/ul>\n<hr \/>\n<h2>7\ufe0f\u20e3 What is the use of <code class=\"\" data-line=\"\">final<\/code>, <code class=\"\" data-line=\"\">static<\/code>, and <code class=\"\" data-line=\"\">this<\/code> keywords in Java?<\/h2>\n<h3>Sample Answer:<\/h3>\n<ul>\n<li><strong>final<\/strong> \u2013 used for constants, preventing inheritance or method overriding.<\/li>\n<li><strong>static<\/strong> \u2013 belongs to class, shared across objects.<\/li>\n<li><strong>this<\/strong> \u2013 refers to current class instance variable.<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<pre>public class Test {\r\n    static int count = 0;\r\n    final int MAX = 10;\r\n\r\n```\r\npublic void setCount(int count){\r\n    this.count = count;\r\n}\r\n```\r\n\r\n}<\/pre>\n<hr \/>\n<h2>8\ufe0f\u20e3 Explain Collection Framework \u2014 where have you used HashMap or ArrayList in your automation?<\/h2>\n<h3>Sample Answer:<\/h3>\n<p>I have used:<\/p>\n<ul>\n<li><strong>ArrayList<\/strong> \u2013 storing multiple WebElements or test data rows.<\/li>\n<li><strong>HashMap<\/strong> \u2013 storing key-value pairs like username-password, column-value mapping.<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<pre>HashMap&lt;String, String&gt; userData = new HashMap&lt;&gt;();\r\nuserData.put(\"username\", \"admin\");\r\nuserData.put(\"password\", \"admin123\");\r\n<\/pre>\n<hr \/>\n<h2>9\ufe0f\u20e3 How do you handle exceptions in Selenium scripts?<\/h2>\n<h3>Sample Answer:<\/h3>\n<ul>\n<li>Using <strong>try-catch blocks<\/strong><\/li>\n<li>Using <strong>throws declaration<\/strong><\/li>\n<li>Custom exception handling in framework<\/li>\n<li>Retry mechanism for flaky tests<\/li>\n<li>Logging errors using Log4j<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<pre>try {\r\n    driver.findElement(By.id(\"login\")).click();\r\n} catch (NoSuchElementException e) {\r\n    System.out.println(\"Element not found\");\r\n}\r\n<\/pre>\n<hr \/>\n<h2>\ud83d\udd1f What\u2019s your approach to data-driven testing using TestNG or Excel?<\/h2>\n<h3>Sample Answer:<\/h3>\n<p>I use <strong>@DataProvider<\/strong> in TestNG to pass multiple test data sets.<\/p>\n<p>For Excel integration:<\/p>\n<ul>\n<li>Use Apache POI to read Excel file.<\/li>\n<li>Store data in Object[][] format.<\/li>\n<li>Pass to @DataProvider method.<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<pre>@DataProvider(name=\"loginData\")\r\npublic Object[][] getData(){\r\n    return new Object[][] {\r\n        {\"admin\",\"admin123\"},\r\n        {\"user\",\"user123\"}\r\n    };\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; QA Automation \u2013 Core Java &amp; Selenium \ud835\udde7\ud835\uddf2\ud835\uddf0\ud835\uddf5\ud835\uddfb\ud835\uddf6\ud835\uddf0\ud835\uddee\ud835\uddf9 Interview Questions 1\ufe0f\u20e3 What are the differences between findElement() and findElements()? Sample Answer: findElement() returns a single WebElement. If the element is not found, it throws NoSuchElementException. findElements() returns a List&lt;WebElement&gt;. If no elements are found, it returns an empty list (does not throw exception). findElement() [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-27961","post","type-post","status-publish","format-standard","hentry","category-automation","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/27961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=27961"}],"version-history":[{"count":1,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/27961\/revisions"}],"predecessor-version":[{"id":27962,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/27961\/revisions\/27962"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=27961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=27961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=27961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}