{"id":1243,"date":"2026-10-14T06:50:23","date_gmt":"2026-10-14T06:50:23","guid":{"rendered":"https:\/\/logicnextgen.com\/tutorials\/?page_id=1243"},"modified":"2026-10-14T11:17:07","modified_gmt":"2026-10-14T11:17:07","slug":"java-selenium-interview-questions-and-answers","status":"publish","type":"page","link":"https:\/\/logicnextgen.com\/tutorials\/java-selenium-interview-questions-and-answers\/","title":{"rendered":"Java Selenium Interview Questions and Answers"},"content":{"rendered":"\n<p class=\"has-text-color has-link-color has-x-large-font-size wp-elements-1 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>Top Java Selenium Interview Questions &amp; Answers<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-2\" style=\"color:#ff8d00\">1. <strong>What is Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Java is a high-level, object-oriented, platform-independent programming language used for developing web, desktop, mobile, and automation applications.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-3\" style=\"color:#ff8d00\"><strong>2. What are the features of Java?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Platform independent<\/li>\n\n\n\n<li>Object-oriented<\/li>\n\n\n\n<li>Secure<\/li>\n\n\n\n<li>Robust<\/li>\n\n\n\n<li>Multithreaded<\/li>\n\n\n\n<li>Portable<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-4\" style=\"color:#ff8d00\"><strong>3. What are variables in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Variables are containers used to store data values.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int age = 25;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-5\" style=\"color:#ff8d00\"><strong>4. What are data types in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Two types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Primitive \u2192 int, char, boolean<\/li>\n\n\n\n<li>Non-primitive \u2192 String, Array, Class<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-6\" style=\"color:#ff8d00\"><strong>5. What is the difference between primitive and non-primitive data types?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Primitive<\/strong><\/td><td><strong>Non-Primitive<\/strong><\/td><\/tr><tr><td>Stores value<\/td><td>Stores reference<\/td><\/tr><tr><td>Fixed size<\/td><td>Dynamic size<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-7\" style=\"color:#ff8d00\"><strong>6. What is type casting in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Converting one datatype into another datatype.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>double d = 10.5;\nint i = (int)d;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-8\" style=\"color:#ff8d00\"><strong>7. What are operators in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Operators perform operations on variables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Arithmetic (+)<\/li>\n\n\n\n<li>Logical (&amp;&amp;)<\/li>\n\n\n\n<li>Relational (&gt;)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-9\" style=\"color:#ff8d00\"><strong>8. What is the difference between <\/strong><strong>==<\/strong><strong> and <\/strong><strong>.equals()<\/strong><strong>?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>==<\/strong><\/td><td><strong>.equals()<\/strong><\/td><\/tr><tr><td>Compares memory reference<\/td><td>Compares values<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-10\" style=\"color:#ff8d00\"><strong>9. What are OOPs concepts in Java?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Encapsulation<\/li>\n\n\n\n<li>Inheritance<\/li>\n\n\n\n<li>Polymorphism<\/li>\n\n\n\n<li>Abstraction<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-11\" style=\"color:#ff8d00\"><strong>10. What is encapsulation?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Encapsulation means wrapping data and methods together in a single class and restricting direct access using private variables.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-12\" style=\"color:#ff8d00\"><strong>11. What is inheritance?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Inheritance allows one class to acquire properties and methods of another class using extends keyword.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-13\" style=\"color:#ff8d00\"><strong>12. What is polymorphism?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Polymorphism means one method can perform different actions based on the object.<br>Types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Overloading<\/li>\n\n\n\n<li>Overriding<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-14\" style=\"color:#ff8d00\"><strong>13. What is abstraction?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Abstraction means hiding implementation details and showing only required functionality.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-15\" style=\"color:#ff8d00\"><strong>14. What is the difference between abstraction and encapsulation?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Abstraction<\/strong><\/td><td><strong>Encapsulation<\/strong><\/td><\/tr><tr><td>Hides implementation<\/td><td>Hides data<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-16\" style=\"color:#ff8d00\"><strong>15. What is method overloading?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Method overloading means creating multiple methods with same name but different parameters.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-17\" style=\"color:#ff8d00\"><strong>16. What is method overriding?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Method overriding means redefining parent class method in child class with same signature.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-18\" style=\"color:#ff8d00\"><strong>17. What is the difference between overloading and overriding?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Overloading<\/strong><\/td><td><strong>Overriding<\/strong><\/td><\/tr><tr><td>Same class<\/td><td>Parent-child class<\/td><\/tr><tr><td>Different parameters<\/td><td>Same parameters<\/td><\/tr><tr><td>Compile-time polymorphism<\/td><td>Runtime polymorphism<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-19\" style=\"color:#ff8d00\"><strong>18. What is an interface in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An interface is a blueprint containing abstract methods that must be implemented by classes.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-20\" style=\"color:#ff8d00\"><strong>19. What is an abstract class?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An abstract class is a class declared using abstract keyword. It can contain abstract and non-abstract methods<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-21\" style=\"color:#ff8d00\"><strong>20. What is the difference between interface and abstract class?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Interface<\/strong><\/td><td><strong>Abstract Class<\/strong><\/td><\/tr><tr><td>Supports multiple inheritance<\/td><td>Partial abstraction<\/td><\/tr><tr><td>Mostly abstract methods<\/td><td>Can contain concrete methods<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-22\" style=\"color:#ff8d00\"><strong>21. What is constructor in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Constructor initializes object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-23\" style=\"color:#ff8d00\"><strong>22. What is constructor overloading?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A constructor is a special method used to initialize objects.<br><\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-24 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>23. What is constructor overloading?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Creating multiple constructors with different parameters is called constructor overloading<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-25\" style=\"color:#ff8d00\"><strong>23. What is the difference between a constructor and a method?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Constructor<\/strong><\/td><td><strong>Method<\/strong><\/td><\/tr><tr><td>Initializes object<\/td><td>Performs operations<\/td><\/tr><tr><td>Same name as class<\/td><td>Any valid name<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-26\" style=\"color:#ff8d00\"><strong>24. What is <\/strong><strong>this<\/strong><strong> keyword?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Refers to current class object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-27\" style=\"color:#ff8d00\"><strong>25. What is <\/strong><strong>super<\/strong><strong> keyword?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">super refers to parent class object or constructor.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-28\" style=\"color:#ff8d00\"><strong>26. What is static keyword in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">static belongs to class instead of object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-29\" style=\"color:#ff8d00\"><strong>27. What is final keyword in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Used to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Prevent inheritance<\/li>\n\n\n\n<li>Prevent overriding<\/li>\n\n\n\n<li>Declare constants<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-30\" style=\"color:#ff8d00\"><strong>28. Can we override static or final methods?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No, static and final methods cannot be overridden.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-31\" style=\"color:#ff8d00\"><strong>29. What is String in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">String is a sequence of characters used to store text.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-32\" style=\"color:#ff8d00\"><strong>30. What is the difference between String, StringBuffer, and StringBuilder?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>String<\/strong><\/td><td><strong>StringBuffer<\/strong><\/td><td><strong>StringBuilder<\/strong><\/td><\/tr><tr><td>Immutable<\/td><td>Mutable<\/td><td>Mutable<\/td><\/tr><tr><td>Slow<\/td><td>Thread-safe<\/td><td>Faster<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-33\" style=\"color:#ff8d00\"><strong>31. Why is String immutable in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For security, thread safety, and performance.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-34\" style=\"color:#ff8d00\"><strong>32. What is string pooling?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Java stores string literals in common memory called String Pool.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-35\" style=\"color:#ff8d00\"><strong>33. What is the difference between <\/strong><strong>equals()<\/strong><strong> and <\/strong><strong>equalsIgnoreCase()<\/strong><strong>?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>equals()<\/strong><\/td><td><strong>equalsIgnoreCase()<\/strong><\/td><\/tr><tr><td>Case-sensitive<\/td><td>Ignores case<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-36\" style=\"color:#ff8d00\"><strong>34. How do you reverse a string in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using StringBuilder:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">String rev = new StringBuilder(str).reverse().toString();<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-37\" style=\"color:#ff8d00\"><strong>35. How do you remove duplicates from a string?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Duplicates can be removed using loops, Set collection, or HashSet.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-38\" style=\"color:#ff8d00\"><strong>36. How do you count characters in a string?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using length() method.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">str.length();<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-39\" style=\"color:#ff8d00\"><strong>37. What is an array in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An array is a collection of elements of the same datatype stored in a single variable. It is used to store multiple values together using index positions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-40\" style=\"color:#ff8d00\"><strong>38. What is ArrayList?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">ArrayList is a class in Java Collection Framework used to store dynamic collections of elements. Unlike arrays, its size can grow or shrink automatically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-41\" style=\"color:#ff8d00\"><strong>39. What is the difference between Array and ArrayList?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Array<\/td><td>ArrayList<\/td><\/tr><tr><td>Fixed size<\/td><td>Dynamic size<\/td><\/tr><tr><td>Stores primitives<\/td><td>Stores objects<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-42\" style=\"color:#ff8d00\"><strong>40. What is the difference between List, Set, and Map?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-43\" style=\"color:#ff8d00\"><strong>41. What is HashMap in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Stores key-value pairs<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-44\" style=\"color:#ff8d00\"><strong>42. What is the difference between HashMap and Hashtable?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>HashMap<\/strong><\/td><td><strong>Hashtable<\/strong><\/td><\/tr><tr><td>Not synchronized<\/td><td>Synchronized<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-45\" style=\"color:#ff8d00\"><strong>43. What is the difference between HashSet and TreeSet?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>HashSet<\/strong><\/td><td><strong>TreeSet<\/strong><\/td><\/tr><tr><td>Unordered<\/td><td>Sorted<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-46\" style=\"color:#ff8d00\"><strong>44. What is an Iterator in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Used to traverse collection elements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-47\" style=\"color:#ff8d00\"><strong>45. What is the difference between Iterator and ListIterator?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Iterator<\/strong><\/td><td><strong>ListIterator<\/strong><\/td><\/tr><tr><td>Forward only<\/td><td>Forward &amp; backward<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-48\" style=\"color:#ff8d00\"><strong>46. What is the Collection Framework in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Framework containing classes\/interfaces for storing data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-49\" style=\"color:#ff8d00\"><strong>47. What is Comparable and Comparator?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Comparable<\/strong><\/td><td><strong>Comparator<\/strong><\/td><\/tr><tr><td>Natural sorting<\/td><td>Custom sorting<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-50\" style=\"color:#ff8d00\"><strong>48. What is the difference between ArrayList and LinkedList?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>ArrayList<\/strong><\/td><td><strong>LinkedList<\/strong><\/td><\/tr><tr><td>Faster retrieval<\/td><td>Faster insertion\/deletion<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-51\" style=\"color:#ff8d00\"><strong>49. What is exception handling in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Mechanism to handle runtime errors.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-52\" style=\"color:#ff8d00\"><strong>50. What is the difference between checked and unchecked exceptions?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Checked<\/strong><\/td><td><strong>Unchecked<\/strong><\/td><\/tr><tr><td>Compile-time<\/td><td>Runtime<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-53\" style=\"color:#ff8d00\"><strong>51. What is a try-catch block?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Used to handle exceptions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-54\" style=\"color:#ff8d00\"><strong>52. What is a finally block?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Always executes whether exception occurs or not.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-55\" style=\"color:#ff8d00\"><strong>53. What is throw and throws keywords?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>throw<\/strong><\/td><td><strong>throws<\/strong><\/td><\/tr><tr><td>Throws exception<\/td><td>Declares exception<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-56\" style=\"color:#ff8d00\"><strong>54. Can a finally block execute without a catch block?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-57\" style=\"color:#ff8d00\"><strong>55. What is NullPointerException?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Occurs when accessing a null object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-58\" style=\"color:#ff8d00\"><strong>56. What is exception propagation?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Passing an exception from one method to another.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-59\" style=\"color:#ff8d00\"><strong>57. What is file handling in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Reading and writing files using Java classes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-60\" style=\"color:#ff8d00\"><strong>58. How do you read data from a file in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>BufferedReader<\/li>\n\n\n\n<li>Scanner<\/li>\n\n\n\n<li>FileReader<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-61\" style=\"color:#ff8d00\"><strong>59. How do you write data into a file?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using FileWriter or BufferedWriter.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-62\" style=\"color:#ff8d00\"><strong>60. What is BufferedReader?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Used to read text efficiently.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-63\" style=\"color:#ff8d00\"><strong>61. What are FileInputStream and FileOutputStream?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Used to read\/write byte data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-64\" style=\"color:#ff8d00\"><strong>62. What is multithreading in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Executing multiple threads simultaneously.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-65\" style=\"color:#ff8d00\"><strong>63. What is a thread in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Smallest unit of execution.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-66\" style=\"color:#ff8d00\"><strong>64. What is the difference between process and thread?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Process<\/strong><\/td><td><strong>Thread<\/strong><\/td><\/tr><tr><td>Independent execution<\/td><td>Part of process<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-67\" style=\"color:#ff8d00\"><strong>65. How do you create a thread in Java?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Thread class<\/li>\n\n\n\n<li>Runnable interface<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-68\" style=\"color:#ff8d00\"><strong>66. What is synchronization?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Prevents multiple threads from accessing shared resources simultaneously.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-69\" style=\"color:#ff8d00\"><strong>67. What is thread sleep?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Pauses thread execution temporarily.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-70 wp-block-paragraph\" style=\"color:#ff8d00\"><br><strong>68. What are Locators in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Locators are used to identify web elements on a webpage so that Selenium can interact with them.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>id<\/li>\n\n\n\n<li>name<\/li>\n\n\n\n<li>className<\/li>\n\n\n\n<li>tagName<\/li>\n\n\n\n<li>linkText<\/li>\n\n\n\n<li>partialLinkText<\/li>\n\n\n\n<li>xpath<\/li>\n\n\n\n<li>cssSelector<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-71 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>69.<\/strong> <strong>What is XPath, and what are the types of <strong>XPath<\/strong>?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">XPath is a locator strategy used to navigate through XML\/HTML DOM structure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Absolute XPath \u2192 starts from root (<code>\/html\/body\/...<\/code>) \u274c not recommended<\/li>\n\n\n\n<li>Relative XPath<strong> <\/strong>\u2192 flexible and stable (<code>\/\/input[@id='email']<\/code>) \u2705<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">XPath is useful for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Dynamic elements<\/li>\n\n\n\n<li>Complex structures<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-align-left has-text-color has-link-color has-medium-font-size wp-elements-72 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>70. What is a page object model?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Page Object Model (POM) is a design pattern used in test automation that helps you create clean, maintainable, and reusable test code \u2014 especially for web applications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In POM, each web page of your application is represented by a separate class (a \u201cPage Object\u201d), and all the elements (buttons, fields, links, etc.) and actions (clicks, form submissions, etc.) on that page are defined as methods in that class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Better Code Organization<br>Keeps UI locators and actions in one place.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Reusability<br>You can use the same page object in multiple tests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Easier Maintenance<br>If a page changes, you update only one file \u2014 not all your test scripts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Improved Readability<br>Tests become more readable and behave like real-world actions.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-73 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>71. What is the role of TestNG in Automation Testing?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:16px\">TestNG is a testing framework that helps organize, execute, and manage automated tests efficiently. It supports features like test grouping, prioritization, parallel execution, and data-driven testing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:16px\">It also generates detailed reports and integrates well with tools like Selenium and CI\/CD pipelines<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-74 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>72. What are Waits in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Waits are used to handle synchronization issues when elements take time to load. Without waits, Selenium may try to interact with elements before they are available, causing failures.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Implicit Wait \u2192 applies globally<\/li>\n\n\n\n<li>Explicit Wait \u2192 waits for specific condition<\/li>\n\n\n\n<li>Fluent Wait \u2192 customizable<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Best practice:<br>Use <strong>Explicit Wait<\/strong> for better control.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-75 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>73. Difference between Implicit and Explicit Wait<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Implicit wait is applied globally and waits for all elements, whereas explicit wait is applied to specific elements based on conditions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Wait until element is clickable<\/li>\n\n\n\n<li>Wait until element is visible<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Explicit wait is preferred because it is more efficient and avoids unnecessary delays.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-76 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>74. How do you handle dropdowns?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Dropdowns are handled using the Select class in Selenium when the HTML uses &lt;select&gt; tag.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can select options using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Visible text<\/li>\n\n\n\n<li>Value<\/li>\n\n\n\n<li>Index<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"> For custom dropdowns (non-select):<br>We use click and XPath.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-77 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>75. How do you handle alerts?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Alerts are popups that require user action. Selenium handles them using switchTo().alert().<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Operations:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>accept() \u2192 click OK<\/li>\n\n\n\n<li>dismiss() \u2192 click Cancel<\/li>\n\n\n\n<li>getText() \u2192 read message<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Important:<br>You must switch to alert before interacting with it.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-78 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>76. What is StaleElementException?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This exception occurs when the element is no longer attached to the DOM. It usually happens when<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Page refreshes<\/li>\n\n\n\n<li>DOM updates dynamically<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"> Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Re-locate the element<\/li>\n\n\n\n<li>Use explicit wait<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-79 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>77. What is Actions class?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Actions class is used to perform advanced user interactions that cannot be done using simple commands<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Mouse hover<\/li>\n\n\n\n<li>Drag and drop<\/li>\n\n\n\n<li>Right-click<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Used in complex UI scenarios.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-80 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>78. What is JavaScriptExecutor?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">JavaScriptExecutor allows executing JavaScript code inside the browser.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Used when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Selenium cannot click element<\/li>\n\n\n\n<li>Need to scroll page<\/li>\n\n\n\n<li>Handle hidden elements<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; js.executeScript(&#8220;window.scrollBy(0,500)&#8221;);<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-81 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>79. What is Data-Driven Testing?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this approach, test data is stored externally (Excel, CSV, JSON), and tests are executed using different data sets.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Benefits:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reusability<\/li>\n\n\n\n<li>Multiple test scenarios<\/li>\n\n\n\n<li>Better coverage<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-82 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>80. How do you handle failures in automation?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Failures are handled using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Retry mechanism<\/li>\n\n\n\n<li>Screenshot capture<\/li>\n\n\n\n<li>Logging (Log4j)<\/li>\n\n\n\n<li>Reports (Extent Reports)<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-83 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>81. What are the different types of navigation commands?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Navigation commands are used to move between pages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Methods:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>get() \u2192 open URL<\/li>\n\n\n\n<li>navigate().to() \u2192 go to URL<\/li>\n\n\n\n<li>navigate().back() \u2192 go back<\/li>\n\n\n\n<li>navigate().forward() \u2192 go forward<\/li>\n\n\n\n<li>navigate().refresh() \u2192 refresh page&nbsp;<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-84 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>82. What is the difference between findElement and findElements?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;findElement \u2192 returns a single element, throws exception if not found<\/li>\n\n\n\n<li>&nbsp;findElements \u2192 returns a list of elements, returns empty list if not found<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-85 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>83. How do you handle frames in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Frames are handled using switchTo().frame().<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>By index<\/li>\n\n\n\n<li>By name\/id<\/li>\n\n\n\n<li>By WebElement<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-86 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>84. What is Page Factory in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Page Factory is an extension of POM that uses @FindBy annotation to initialize elements.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-87 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>85. What is Fluent Wait?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Fluent Wait is an advanced wait with customizable timeout and polling interval.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;&nbsp;Ignore specific exceptions<\/li>\n\n\n\n<li>&nbsp;&nbsp;Set polling frequency<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-88 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>86. What are common exceptions in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>NoSuchElementException<\/li>\n\n\n\n<li>TimeoutException<\/li>\n\n\n\n<li>StaleElementReferenceException<\/li>\n\n\n\n<li>ElementNotInteractableException<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-89 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>87. How do you capture screenshots in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using TakesScreenshot interface.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Failure analysis<\/li>\n\n\n\n<li>&nbsp;Reporting<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-90 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>88. How do you scroll a webpage in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using JavaScriptExecutor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;scrollBy()<\/li>\n\n\n\n<li>&nbsp;scrollIntoView()<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-91 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>89. How do you handle multiple windows\/tabs?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;Use getWindowHandles() and switchTo().window()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Store window IDs<\/li>\n\n\n\n<li>&nbsp;Switch between them<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-92 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>90. How do you implement retry logic in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using TestNG RetryAnalyzer or custom logic to rerun failed tests.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-93 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>91. How do you design a scalable automation framework?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Use:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Page Object Model<\/li>\n\n\n\n<li>&nbsp;Reusable utilities<\/li>\n\n\n\n<li>&nbsp;Data-driven approach<\/li>\n\n\n\n<li>&nbsp;Proper logging &amp; reporting<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-94 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>92. What is the difference between Hard Assert and Soft Assert?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Hard Assert \u2192 stops execution on failure<\/li>\n\n\n\n<li>&nbsp;Soft Assert \u2192 continues execution and reports all failures at end<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-95 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>93. How do you integrate Selenium with CI\/CD?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Using tools like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Jenkins<\/li>\n\n\n\n<li>&nbsp;GitHub Actions<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Trigger tests on build<\/li>\n\n\n\n<li>&nbsp;Run tests automatically<\/li>\n\n\n\n<li>&nbsp;Generate reports<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-96 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>94. What is logging in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Logging helps track test execution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tools:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Log4j<\/li>\n\n\n\n<li>&nbsp;SLF4J<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-97 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>95. How do you parameterize tests in TestNG?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;Using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;@DataProvider<\/li>\n\n\n\n<li>&nbsp;@Test parameters<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-98 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>96. What are best practices in Selenium automation?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Use stable locators<\/li>\n\n\n\n<li>&nbsp;Avoid Thread.sleep<\/li>\n\n\n\n<li>&nbsp;Use Page Object Model (POM)<\/li>\n\n\n\n<li>&nbsp;Keep tests independent<\/li>\n\n\n\n<li>&nbsp;Maintain reusable code<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-99 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>97.What is broken link?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A broken link is a hyperlink that does not work or leads to an error page (like 404 Not Found), usually because the target page is missing or invalid.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-100 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>98. What is the difference between driver.close() and driver.quit()?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>driver.close() \u2192 closes current browser window<\/li>\n\n\n\n<li>driver.quit() \u2192 closes all browser windows and ends session<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-101 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>99. What is getText() vs getAttribute()?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>getText() \u2192 gets visible text<\/li>\n\n\n\n<li>getAttribute() \u2192 gets attribute value (like value, href)<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-102 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>100. What is a WebElement?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">WebElement represents an HTML element in Selenium.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Used to perform actions like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>click()<\/li>\n\n\n\n<li>sendKeys()<\/li>\n\n\n\n<li>getText()<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-103 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>101. What is Maven in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Maven is a build automation tool.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Managing dependencies<\/li>\n\n\n\n<li>Running tests<\/li>\n\n\n\n<li>Project structure<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-104 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>102. What is Jenkins in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Jenkins is a CI\/CD tool used to automate test execution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Scheduling test runs<\/li>\n\n\n\n<li>Integrating with Git<\/li>\n\n\n\n<li>Generating reports<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-105 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>103. How do you check if an element is displayed on the page?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Methods:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>isDisplayed()<\/li>\n\n\n\n<li>isEnabled()<\/li>\n\n\n\n<li>isSelected()<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Used for validation in test cases<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-106 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>104. What is the difference between click() and submit()?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>click(): Clicks any element<\/li>\n\n\n\n<li>submit(): submit a form<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-107 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>105. How do you handle disabled elements?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Selenium cannot interact directly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use JavaScriptExecutor<\/li>\n\n\n\n<li>Remove disabled attribute<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-108 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>106. What is the difference between getWindowHandle() and getWindowHandles()?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>getWindowHandle(): Returns single window ID<\/li>\n\n\n\n<li>getWindowHandles(): Returns all window IDs<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-109 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>107. How do you handle dynamic tables?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Locate table<\/li>\n\n\n\n<li>Use loops for rows and columns<\/li>\n\n\n\n<li>Use dynamic XPath<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-110 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>108. What is the best wait strategy in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Best practice:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use Explicit Wait<\/li>\n\n\n\n<li>Avoid mixing waits<\/li>\n\n\n\n<li>Avoid Thread.sleep()<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-111 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>109. How do you ensure your automation is stable?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Best practices:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use stable locators<\/li>\n\n\n\n<li>Use waits properly<\/li>\n\n\n\n<li>Keep tests independent<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-112 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>110 .How do you handle auto-suggestions (like Google search)?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enter text<\/li>\n\n\n\n<li>Capture suggestions<\/li>\n\n\n\n<li>Loop and select<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-113 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>111. What is DOM in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DOM (Document Object Model) represents the structure of a webpage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Locating elements<\/li>\n\n\n\n<li>Understanding hierarchy<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-114 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>112. How do you handle dynamic elements in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Dynamic elements change attributes like id or class at runtime.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use relative XPath<\/li>\n\n\n\n<li>Use functions like: contains() ,starts-with()<\/li>\n\n\n\n<li>Use stable attributes<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<br>\/\/input[contains(@id,&#8217;user&#8217;)]<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-115 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>113. What will you do if your script fails randomly?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is called flaky tests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Approach:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add proper waits (Explicit Wait)<\/li>\n\n\n\n<li>Check synchronization issues<\/li>\n\n\n\n<li>Verify locators<\/li>\n\n\n\n<li>Add logging and screenshots<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-116 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>114. How do you handle file upload in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If input type=&#8221;file&#8221;:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use sendKeys() with file path<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If custom upload:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use AutoIT or Robot class<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-117 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>115. How do you handle file download?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Selenium cannot directly handle OS-level downloads.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set browser download preferences<\/li>\n\n\n\n<li>Verify file in download folder<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-118 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>116. How do you validate broken links?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Get all links using findElements(By.tagName(&#8220;a&#8221;))<\/li>\n\n\n\n<li>Use HTTP connection<\/li>\n\n\n\n<li>Check response code<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Codes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>200 \u2192 OK<\/li>\n\n\n\n<li>404 \u2192 Broken<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-119 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>117. How do you scroll to a specific element?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using JavaScriptExecutor:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">scrollIntoView()<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-120 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>118. How do you handle shadow DOM elements?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Shadow DOM elements are hidden inside shadow root.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use JavaScriptExecutor<\/li>\n\n\n\n<li>Access shadowRoot<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-121 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>119. What is the difference between driver.get() and driver.navigate().to()?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">get():<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Waits for page load<\/li>\n\n\n\n<li>Used for initial load<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">navigate().to():<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Similar but used for navigation<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-122 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>120. How do you run tests in parallel in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using TestNG:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>parallel=&#8221;methods&#8221; or &#8220;classes&#8221; in XML<\/li>\n\n\n\n<li>Use Selenium Grid<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-123 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>121. How do you manage test data?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Excel (Apache POI)<\/li>\n\n\n\n<li>JSON<\/li>\n\n\n\n<li>DataProvider in TestNG<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-124 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>122. How do you handle stale element exceptions in real projects?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Re-locate element<\/li>\n\n\n\n<li>Use Explicit Wait<\/li>\n\n\n\n<li>Avoid storing WebElement for long<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-125 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>123. What challenges did you face in automation?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Dynamic elements<\/li>\n\n\n\n<li>Synchronization issues<\/li>\n\n\n\n<li>Browser compatibility<\/li>\n\n\n\n<li>Slow execution<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-126 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>124. How do you identify if an element is not clickable?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Visibility<\/li>\n\n\n\n<li>Enabled state<\/li>\n\n\n\n<li>Overlapping elements<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Use:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Explicit Wait \u2192 elementToBeClickable<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-127 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>125. How do you debug a failed test case?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check logs<\/li>\n\n\n\n<li>Check screenshots<\/li>\n\n\n\n<li>Re-run test<\/li>\n\n\n\n<li>Validate locators<\/li>\n\n\n\n<li>Check environment<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-128 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>126. How do you handle cookies in Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Methods:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>addCookie()<\/li>\n\n\n\n<li>getCookies()<\/li>\n\n\n\n<li>deleteCookie()<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-129 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>127. How do you integrate your framework with CI\/CD?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Push code to Git<\/li>\n\n\n\n<li>Configure Jenkins job<\/li>\n\n\n\n<li>Trigger build<\/li>\n\n\n\n<li>Run tests<\/li>\n\n\n\n<li>Generate report<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-130 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>128. How do you capture screenshots only on failure?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>TestNG listeners (ITestListener)<\/li>\n\n\n\n<li>Take screenshot in onTestFailure()<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-131 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>129. What is the difference between Absolute and Relative path?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Absolute:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Full path<\/li>\n\n\n\n<li>Not stable<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Relative:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Flexible<\/li>\n\n\n\n<li>Recommended<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-132 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>130. Your test works in Chrome but fails in Firefox. What will you do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Possible reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Different browser behavior<\/li>\n\n\n\n<li>Locator compatibility issues<\/li>\n\n\n\n<li>Timing issues<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use cross-browser compatible locators<\/li>\n\n\n\n<li>Add explicit waits<\/li>\n\n\n\n<li>Use browser-specific options if needed<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-133 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>131. Element is visible but Selenium is unable to click it. Why?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Possible causes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Element overlapped by another element<\/li>\n\n\n\n<li>Element not clickable yet<\/li>\n\n\n\n<li>Hidden behind loader<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use Explicit Wait \u2192 elementToBeClickable<\/li>\n\n\n\n<li>Scroll into view<\/li>\n\n\n\n<li>Use JavaScriptExecutor click as fallback<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-134 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>132. Your XPath is correct but still element is not found. What could be wrong?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Element inside iframe<\/li>\n\n\n\n<li>Element inside shadow DOM<\/li>\n\n\n\n<li>Page not fully loaded<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Switch to frame<\/li>\n\n\n\n<li>Handle shadow root<\/li>\n\n\n\n<li>Use wait<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-135 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>133. How do you automate a page where elements load after scrolling?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use JavaScriptExecutor to scroll<\/li>\n\n\n\n<li>Load elements dynamically<\/li>\n\n\n\n<li>Use loop until element appears<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-136 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>134. How do you handle a situation where element ID changes every time?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use contains() or starts-with()<\/li>\n\n\n\n<li>Use parent-child XPath<\/li>\n\n\n\n<li>Use other stable attributes<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-137 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>135. Your test passes locally but fails in Jenkins. Why?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Common reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Environment difference<\/li>\n\n\n\n<li>Headless mode issues<\/li>\n\n\n\n<li>Timing issues<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add proper waits<\/li>\n\n\n\n<li>Check environment configs<\/li>\n\n\n\n<li>Add logging<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-138 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>136. How do you design your framework for multiple users\/logins?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use DataProvider<\/li>\n\n\n\n<li>Store test data externally<\/li>\n\n\n\n<li>Parameterize login<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-139 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>137. How do you handle a calendar\/date picker?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Simple \u2192 sendKeys()<\/li>\n\n\n\n<li>Complex \u2192 click through UI<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open calendar<\/li>\n\n\n\n<li>Navigate month\/year<\/li>\n\n\n\n<li>Select date<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-140 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>138. How do you handle pagination (multiple pages)?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Loop through pages<\/li>\n\n\n\n<li>Click \u201cNext\u201d button<\/li>\n\n\n\n<li>Extract data until last page<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-141 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>139. How do you verify if a file is successfully downloaded?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps<strong>:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set download directory<\/li>\n\n\n\n<li>Check file existence<\/li>\n\n\n\n<li>Validate file name<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-142 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>140. What will you do if execution is very slow?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Optimization:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Run tests in parallel<\/li>\n\n\n\n<li>Remove Thread.sleep()<\/li>\n\n\n\n<li>Use headless mode<\/li>\n\n\n\n<li>Optimize locators<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-143 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>141. How do you handle dependency between test cases?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Avoid dependency (best practice)<\/li>\n\n\n\n<li>Use TestNG dependsOnMethods if needed<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-144 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>142. How do you test a login page with multiple invalid inputs?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Approach:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use DataProvider<\/li>\n\n\n\n<li>Pass multiple datasets<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Invalid username<\/li>\n\n\n\n<li>Invalid password<\/li>\n\n\n\n<li>Empty fields<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-145 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>143. What if application UI changes frequently?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Solution:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use POM design<\/li>\n\n\n\n<li>Centralize locators<\/li>\n\n\n\n<li>Use stable attributes<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-146 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>144. How do you validate error messages?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Capture element text<\/li>\n\n\n\n<li>Compare with expected<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Use:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">assertEquals()<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-147 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>145. <\/strong><strong>What are the test types supported by Selenium?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For testing web-based applications, Selenium can be used.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The test types supported by Selenium are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Functional testing: It verifies if each function of a software application performs in accordance with specific requirements. This testing primarily involves black-box testing, and it is not concerned with the source code of the application.<\/li>\n\n\n\n<li>&nbsp;Regression testing: It is nothing but a full or partial selection of the already executed&nbsp;test cases to be re-executed to ensure that the existing functionalities work fine.<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-148 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>146. In Selenium, what are breakpoints and start points?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Breakpoints: Breakpoints are used to stall the execution of the test. The execution will stop whenever a breakpoint is implemented, and this will help us check whether the code is working properly or not.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Start points: Start points are the points from where the execution should begin. Start points can be&nbsp;used when we want to run the test script from the middle of the code or after a breakpoint.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-149 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>147. What is DOM inspection?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>I<\/strong>nspecting webpage structure using browser DevTools.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Locators<\/li>\n\n\n\n<li>XPath<\/li>\n\n\n\n<li>CSS selectors<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-150\" style=\"color:#ff8d00\"><strong>148. What are the latest features in Selenium 4?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Relative locators<\/li>\n\n\n\n<li>Selenium Manager<\/li>\n\n\n\n<li>Improved Grid<\/li>\n\n\n\n<li>Better DevTools support<\/li>\n\n\n\n<li>New window\/tab handling<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-151\" style=\"color:#ff8d00\"><strong>149. What is smoke suite in automation?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Small set of critical test cases executed after every build.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Purpose:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Verify build stability quickly.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-152\" style=\"color:#ff8d00\"><strong>150. What is a locator strategy hierarchy?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Preferred locator order:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>ID<\/li>\n\n\n\n<li>Name<\/li>\n\n\n\n<li>CSS Selector<\/li>\n\n\n\n<li>XPath<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Because IDs are fastest and most stable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-153\" style=\"color:#ff8d00\"><strong>151. What are flaky tests?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Tests that:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pass sometimes<\/li>\n\n\n\n<li>Fail sometimes<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Timing issues<\/li>\n\n\n\n<li>Dynamic elements<\/li>\n\n\n\n<li>Environment instability<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-154\" style=\"color:#ff8d00\"><strong>152. How do you reduce flaky tests?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use explicit waits<\/li>\n\n\n\n<li>Stable locators<\/li>\n\n\n\n<li>Retry mechanism<\/li>\n\n\n\n<li>Proper synchronization<\/li>\n\n\n\n<li>Independent tests<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-155\" style=\"color:#ff8d00\"><strong>153. What metrics do you track in automation?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pass\/fail percentage<\/li>\n\n\n\n<li>Automation coverage<\/li>\n\n\n\n<li>Execution time<\/li>\n\n\n\n<li>Defect leakage<\/li>\n\n\n\n<li>Stability rate<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-156\" style=\"color:#ff8d00\"><strong>154. What reporting tools are used with Selenium?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Popular reporting tools:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Extent Reports<\/li>\n\n\n\n<li>Allure Reports<\/li>\n\n\n\n<li>TestNG Reports<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-157\" style=\"color:#ff8d00\"><strong>155. What is Extent Report?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Advanced HTML reporting library used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Logs<\/li>\n\n\n\n<li>Screenshots<\/li>\n\n\n\n<li>Execution reports<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-158\" style=\"color:#ff8d00\"><strong>156. What is the difference between verification and validation?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong><em>Verification<\/em><\/strong><\/td><td><strong><em>Validation<\/em><\/strong><\/td><\/tr><tr><td><em>C<\/em>hecks whether product is built correctly<\/td><td>Checks whether correct product is built<\/td><\/tr><tr><td>Process-oriented<\/td><td>Product-oriented<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-159\" style=\"color:#ff8d00\"><strong>157. What is ThreadLocal in Selenium?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Used in parallel execution to maintain separate WebDriver instances per thread.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example use:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Parallel test execution in TestNG<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-160\" style=\"color:#ff8d00\"><strong>158. How do you automate OTP-based login?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Usually OTP is not automated directly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Approaches:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Disable OTP in test environment<\/li>\n\n\n\n<li>Fetch OTP from database\/API\/email<\/li>\n\n\n\n<li>Use static OTP in lower environments<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-161\" style=\"color:#ff8d00\"><strong>159. What if developer changes locator frequently?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use relative XPath\/CSS<\/li>\n\n\n\n<li>Coordinate with developers<\/li>\n\n\n\n<li>Add stable attributes like data-testid<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-162\" style=\"color:#ff8d00\"><strong>160. How do you validate large datasets in UI?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Database comparison<\/li>\n\n\n\n<li>API validation<\/li>\n\n\n\n<li>Dynamic table handling<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-163\" style=\"color:#ff8d00\"><strong>161. What if test data is unavailable?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Approaches:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Generate test data dynamically<\/li>\n\n\n\n<li>Use APIs\/database<\/li>\n\n\n\n<li>Mock services<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-164\" style=\"color:#ff8d00\"><strong>162. How do you manage secrets\/passwords in framework?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Never hardcode credentials.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Environment variables<\/li>\n\n\n\n<li>Vault tools<\/li>\n\n\n\n<li>Encrypted config<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-165\" style=\"color:#ff8d00\"><strong>163. How do you validate images on webpage?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Image displayed<\/li>\n\n\n\n<li>HTTP response<\/li>\n\n\n\n<li>Natural width &gt; 0<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-166\" style=\"color:#ff8d00\"><strong>164. How do you handle hidden elements?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>JavaScriptExecutor<\/li>\n\n\n\n<li>Actions class<\/li>\n\n\n\n<li>Wait until visible<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-167\" style=\"color:#ff8d00\"><strong>165.What will you do if there are no unique locators?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Relative XPath<\/li>\n\n\n\n<li>Parent-child relationship<\/li>\n\n\n\n<li>CSS hierarchy<\/li>\n\n\n\n<li>Multiple attributes<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-168\" style=\"color:#ff8d00\"><strong>166. What is a Keyword-Driven Framework?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A Keyword-Driven Framework is an automation framework where test actions are represented using predefined keywords like <code>Click<\/code>, <code>Type<\/code>, and <code>Login<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The test data, locators, and actions are maintained separately from the test scripts, making the framework more reusable, maintainable, and easy to understand.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-169\" style=\"color:#ff8d00\"><strong>167. What is TestNG?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><br>TestNG (Test Next Generation) is a testing framework inspired by JUnit and NUnit but designed to be more powerful and flexible. It supports annotations, parallel execution, data-driven testing, and reporting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-170\" style=\"color:#ff8d00\"><strong>168. What are the main features of TestNG?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><br>TestNG (Test Next Generation) is a testing framework inspired by JUnit and NUnit but designed to be more powerful and flexible. It supports annotations, parallel execution, data-driven testing, and reporting.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Annotation-based testing<\/li>\n\n\n\n<li>Parallel test execution<\/li>\n\n\n\n<li>Data-driven testing using DataProvider<\/li>\n\n\n\n<li>Flexible test configuration<\/li>\n\n\n\n<li>Dependency management<\/li>\n\n\n\n<li>Detailed reporting<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-171\" style=\"color:#ff8d00\"><strong>169. What are TestNG annotations?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><br><\/strong> Annotations define how methods should behave in a test. Common ones include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>@Test \u2013 marks a test method<\/li>\n\n\n\n<li>@BeforeMethod \/ @AfterMethod<\/li>\n\n\n\n<li>@BeforeClass \/ @AfterClass<\/li>\n\n\n\n<li>@BeforeSuite \/ @AfterSuite<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-172\" style=\"color:#ff8d00\"><strong>170. What is the difference between @BeforeMethod and @BeforeClass?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>@BeforeMethod: runs <strong>before each test method<\/strong><\/li>\n\n\n\n<li>@BeforeClass: runs <strong>once before all test methods in a class<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-173\" style=\"color:#ff8d00\"><strong>171. What is the difference between TestNG and JUnit?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>TestNG<\/strong><\/td><td><strong>JUnit<\/strong><\/td><\/tr><tr><td>Supports parallel execution<\/td><td>Limited parallel support<\/td><\/tr><tr><td>Supports dependency testing<\/td><td>No dependency feature<\/td><\/tr><tr><td>Supports DataProvider<\/td><td>Limited parameterization<\/td><\/tr><tr><td>More flexible annotations<\/td><td>Fewer annotations<\/td><\/tr><tr><td>Better reporting<\/td><td>Basic reporting<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-174\" style=\"color:#ff8d00\"><strong>172. What is <\/strong><strong>testng.xml<\/strong><strong> file?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">testng.xml is a configuration file used to control test execution in TestNG.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It helps to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Define test suites<\/li>\n\n\n\n<li>Group tests<\/li>\n\n\n\n<li>Run tests in parallel<\/li>\n\n\n\n<li>Pass parameters<\/li>\n\n\n\n<li>Control execution order<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;suite name=\"Suite\"&gt;\n  &lt;test name=\"Test\"&gt;\n     &lt;classes&gt;\n        &lt;class name=\"tests.LoginTest\"\/&gt;\n     &lt;\/classes&gt;\n  &lt;\/test&gt;\n&lt;\/suite<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-175\" style=\"color:#ff8d00\"><strong>173. What are groups in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Groups are used to categorize test methods.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Test(groups = \"smoke\")\npublic void loginTest() {\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can run only specific groups using testng.xml.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-176\" style=\"color:#ff8d00\"><strong>174. What is the use of <code>dependsOnGroups<\/code> in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It allows a test method to depend on an entire group of tests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Groups are used to categorize test methods.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Test(groups = \"smoke\")\npublic void loginTest() {\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can run only specific groups using testng.xml.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-177 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>175. What is dependency in TestNG?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Dependency means one test method depends on another test method.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Test\npublic void login() {\n}\n\n@Test(dependsOnMethods = \"login\")\npublic void dashboard() {\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If login() fails, dashboard() will be skipped.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-178 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>176. What is the difference between Hard Assert and Soft Assert?<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\">Hard Assert<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Stops execution immediately if assertion fails.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>Assert.assertEquals(actual, expected);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading has-medium-font-size\">Soft Assert<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Continues execution even after assertion failure.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>SoftAssert sa = new SoftAssert();\nsa.assertEquals(actual, expected);\nsa.assertAll();<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-179\" style=\"color:#ff8d00\"><strong>177. What is assertion in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Assertions are used to validate expected and actual results.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Common assertions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>assertEquals()<\/li>\n\n\n\n<li>assertTrue()<\/li>\n\n\n\n<li>assertFalse()<\/li>\n\n\n\n<li>assertNull()<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-180\" style=\"color:#ff8d00\"><strong>178. What is parameterization in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Parameterization allows passing values to test methods from testng.xml.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;parameter name=\"browser\" value=\"chrome\"\/&gt;\n@Parameters(\"browser\")\n@Test\npublic void launch(String browser) {\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-181\" style=\"color:#ff8d00\"><strong>179. What is the difference between Parameters and DataProvider?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Parameters<\/strong><\/td><td><strong>DataProvider<\/strong><\/td><\/tr><tr><td>Values from XML<\/td><td>Values from Java method<\/td><\/tr><tr><td>Used for simple data<\/td><td>Used for multiple datasets<\/td><\/tr><tr><td>Less flexible<\/td><td>More flexible<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-182\" style=\"color:#ff8d00\"><strong>180. How can you run tests in parallel in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using parallel attribute in testng.xml.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;suite name=\"Suite\" parallel=\"tests\" thread-count=\"2\"&gt;<br><br><\/code><\/pre>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-183 wp-block-paragraph\" style=\"color:#ff8d00\">1<strong>81. What is invocationCount in TestNG?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is used to run a test multiple times.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Test(invocationCount = 5)\npublic void testMethod() {\n}<\/code><\/pre>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-184 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>182. What is priority in TestNG?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Priority controls execution order of test methods.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Test(priority = 1)\npublic void login() {\n}\n\n@Test(priority = 2)\npublic void logout() {\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Lower priority executes first.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-185\" style=\"color:#ff8d00\"><strong>183. What happens if priority is not set?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Test methods execute in alphabetical order by method name.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-186\" style=\"color:#ff8d00\"><strong>184. What is timeout in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Timeout defines maximum execution time for a test.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Test(timeOut = 3000)\npublic void test() {\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Test fails if execution exceeds 3 seconds.<br><\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-187 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>185. What is enabled=false in TestNG?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Used to skip a test method.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Test(enabled = false)\npublic void skipTest() {\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-188\" style=\"color:#ff8d00\"><strong>186. What is the difference between <\/strong><strong>@BeforeTest<\/strong><strong> and <\/strong><strong>@BeforeSuite<\/strong><strong>?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>@BeforeTest<\/strong><\/td><td><strong>@BeforeSuite<\/strong><\/td><\/tr><tr><td>Runs before test tag<\/td><td>Runs before entire suite<\/td><\/tr><tr><td>Executes multiple times<\/td><td>Executes once<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-189\" style=\"color:#ff8d00\"><strong>187. How do you skip a test in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Two ways:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>enabled = false<\/li>\n\n\n\n<li>Using SkipException<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>throw new SkipException(\"Skipping test\")<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-190\" style=\"color:#ff8d00\"><strong>188. What are listeners in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Listeners are interfaces that modify TestNG behavior during execution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Common listeners:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ITestListener<\/li>\n\n\n\n<li>ISuiteListener<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Logging<\/li>\n\n\n\n<li>Screenshots<\/li>\n\n\n\n<li>Reporting<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-191\" style=\"color:#ff8d00\"><strong>189. What is <\/strong><strong>ITestListener<\/strong><strong>?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It is a listener interface used to track test execution events.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Methods include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>onTestStart()<\/li>\n\n\n\n<li>onTestSuccess()<\/li>\n\n\n\n<li>onTestFailure()<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-192\" style=\"color:#ff8d00\"><strong>190. How do you generate reports in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">TestNG automatically generates reports inside the test-output folder.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Main reports:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>index.html<\/li>\n\n\n\n<li>emailable-report.html<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-193\" style=\"color:#ff8d00\"><strong>191. What is factory annotation in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">@Factory is used to create multiple instances of test classes dynamically.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-194\" style=\"color:#ff8d00\"><strong>192. What is the difference between <\/strong><strong>@BeforeTest<\/strong><strong> and <\/strong><strong>@BeforeMethod<\/strong><strong>?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>@BeforeTest<\/strong><\/td><td><strong>@BeforeMethod<\/strong><\/td><\/tr><tr><td>Runs before all test methods in a test<\/td><td>Runs before each test method<\/td><\/tr><tr><td>Executes once<\/td><td>Executes multiple times<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-195\" style=\"color:#ff8d00\"><strong>193. Can TestNG be integrated with Selenium?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. TestNG is widely used with Selenium for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Test execution<\/li>\n\n\n\n<li>Reporting<\/li>\n\n\n\n<li>Assertions<\/li>\n\n\n\n<li>Parallel testing<\/li>\n\n\n\n<li>Data-driven testing<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-196 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>194. How do you retry failed test cases in TestNG?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using IRetryAnalyzer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class Retry implements IRetryAnalyzer {\n  int count = 0;\n\n  public boolean retry(ITestResult result) {\n     if(count &lt; 2) {\n        count++;\n        return true;\n     }\n     return false;\n  }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-197\" style=\"color:#ff8d00\"><strong>195. What is alwaysRun=true in TestNG?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It ensures the method executes even if dependent methods fail.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Test(alwaysRun = true)<\/code><\/pre>\n\n\n\n<p class=\"has-text-color has-link-color has-medium-font-size wp-elements-198 wp-block-paragraph\" style=\"color:#ff8d00\"><strong>196. What is thread-count in TestNG?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It defines the number of threads used during parallel execution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>thread-count=\"3\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-199\" style=\"color:#ff8d00\"><strong>197. What is Page Object Model (POM)?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Page Object Model is a design pattern in Selenium automation where each web page is represented as a separate class.<br>The class contains:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Web elements of the page<\/li>\n\n\n\n<li>Methods to perform actions on those elements<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It helps improve:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Code reusability<\/li>\n\n\n\n<li>Maintainability<\/li>\n\n\n\n<li>Readability<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-200\" style=\"color:#ff8d00\"><strong>198. Why do we use POM in Selenium?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">POM is used to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reduce code duplication<\/li>\n\n\n\n<li>Separate test logic from page elements<\/li>\n\n\n\n<li>Make framework easy to maintain<\/li>\n\n\n\n<li>Handle UI changes easily<\/li>\n\n\n\n<li>Improve scalability of automation framework<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-201\" style=\"color:#ff8d00\"><strong>199. What are the main components of POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Main components are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Page Class<\/strong> \u2192 Contains locators and methods<\/li>\n\n\n\n<li><strong>Test Class<\/strong> \u2192 Contains test cases<\/li>\n\n\n\n<li><strong>Object Repository<\/strong> \u2192 Stores web element locators<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-202\" style=\"color:#ff8d00\"><strong>200. What are the advantages of POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Advantages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Better code organization<\/li>\n\n\n\n<li>Easy maintenance<\/li>\n\n\n\n<li>Reusable methods<\/li>\n\n\n\n<li>Improved readability<\/li>\n\n\n\n<li>Reduced duplication<\/li>\n\n\n\n<li>Easy debugging<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-203\" style=\"color:#ff8d00\"><strong>201. How does POM improve maintainability?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If a locator changes in UI, we update it only in the Page Class instead of updating in all test cases.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-204\" style=\"color:#ff8d00\"><strong>202. What is Page Factory in Selenium?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Page Factory is an inbuilt Selenium class used to implement POM easily using annotations like @FindBy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@FindBy(id=\"username\")\nWebElement userName;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-205\" style=\"color:#ff8d00\"><strong>203. Difference between POM and Page Factory?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>POM<\/strong><\/td><td><strong>Page Factory<\/strong><\/td><\/tr><tr><td>Uses normal findElement()<\/td><td>Uses @FindBy annotations<\/td><\/tr><tr><td>Elements initialized manually<\/td><td>Elements initialized automatically<\/td><\/tr><tr><td>More coding required<\/td><td>Less coding required<\/td><\/tr><tr><td>Slower compared to Page Factory<\/td><td>Faster initialization<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-206\" style=\"color:#ff8d00\"><strong>204. What is the use of @FindBy annotation?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">@FindBy is used to locate web elements in Page Factory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@FindBy(xpath=\"\/\/input&#91;@id='email']\")\nWebElement email;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-207\" style=\"color:#ff8d00\"><strong>205. What is PageFactory.initElements()?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It initializes all web elements present in the Page Class.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PageFactory.initElements(driver, this);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-208\" style=\"color:#ff8d00\"><strong>206. How do you create a Page Class in POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class LoginPage {\n&nbsp;&nbsp;&nbsp;WebDriver driver;\n&nbsp;&nbsp;&nbsp;@FindBy(id=\"username\")\n&nbsp;&nbsp;&nbsp;WebElement username;\n&nbsp;&nbsp;&nbsp;@FindBy(id=\"password\")\n&nbsp;&nbsp;&nbsp;WebElement password;\n&nbsp;&nbsp;&nbsp;@FindBy(id=\"login\")\n&nbsp;&nbsp;&nbsp;WebElement loginBtn;\n&nbsp;&nbsp;&nbsp;LoginPage(WebDriver driver){\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.driver = driver;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PageFactory.initElements(driver, this);\n&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;public void login(String user, String pass){\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username.sendKeys(user);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password.sendKeys(pass);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loginBtn.click();\n&nbsp;&nbsp;&nbsp;}\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-209\" style=\"color:#ff8d00\"><strong>207. What is the role of constructor in POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Constructor is used to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Initialize WebDriver<\/li>\n\n\n\n<li>Initialize web elements using PageFactory<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-210\" style=\"color:#ff8d00\"><strong>208. Can we use POM without Page Factory?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes.<br>We can implement POM using normal findElement() methods without using Page Factory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-211\" style=\"color:#ff8d00\"><strong>209. What is the difference between Page Class and Test Class?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Page Class<\/strong><\/td><td><strong>Test Class<\/strong><\/td><\/tr><tr><td>Contains locators and methods<\/td><td>Contains test cases<\/td><\/tr><tr><td>Represents webpage<\/td><td>Executes validations<\/td><\/tr><tr><td>Reusable<\/td><td>Uses page methods<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-212\" style=\"color:#ff8d00\"><strong>210. How does POM support reusability?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Common methods like login, click, search, etc. can be reused across multiple test cases.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-213\" style=\"color:#ff8d00\"><strong>211. What type of framework commonly uses POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">POM is commonly used in:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Hybrid Framework<\/li>\n\n\n\n<li>Data-Driven Framework<\/li>\n\n\n\n<li>Keyword-Driven Framework<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-214\" style=\"color:#ff8d00\"><strong>212. What are best practices in POM?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Keep locators private<\/li>\n\n\n\n<li>Use meaningful method names<\/li>\n\n\n\n<li>Avoid hard coding<\/li>\n\n\n\n<li>Use reusable methods<\/li>\n\n\n\n<li>Maintain separate test and page classes<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-215\" style=\"color:#ff8d00\"><strong>213. How do you handle dynamic elements in POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Dynamic elements can be handled using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Dynamic XPath<\/li>\n\n\n\n<li>Explicit waits<\/li>\n\n\n\n<li>Relative locators<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@FindBy(xpath=\"\/\/button&#91;contains(text(),'Login')]\")\nWebElement loginBtn;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-216\" style=\"color:#ff8d00\"><strong>214. Can POM be used with TestNG?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes.<br>POM is commonly integrated with TestNG for test execution, assertions, and reporting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-217\" style=\"color:#ff8d00\"><strong>215. Why is POM considered a good design pattern?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Because it follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Separation of concerns<\/li>\n\n\n\n<li>Encapsulation<\/li>\n\n\n\n<li>Reusability<\/li>\n\n\n\n<li>Maintainability<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-218\" style=\"color:#ff8d00\"><strong>216. What is encapsulation in POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Web elements are hidden inside Page Classes and accessed only through methods.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public void clickLogin(){\n&nbsp;&nbsp;&nbsp;loginBtn.click();\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-219\" style=\"color:#ff8d00\"><strong>217. How do you manage waits in POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Waits are usually implemented inside page methods using Explicit Wait.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));\nwait.until(ExpectedConditions.visibilityOf(loginBtn));<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-220\" style=\"color:#ff8d00\"><\/h3>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-221\" style=\"color:#ff8d00\"><strong>218. How do you handle multiple pages in POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create separate Page Classes for each webpage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>LoginPage.java<\/li>\n\n\n\n<li>HomePage.java<\/li>\n\n\n\n<li>CartPage.java<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-222\" style=\"color:#ff8d00\"><strong>219. What is Base Class in POM framework?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Base Class contains common setup code like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Browser launch<\/li>\n\n\n\n<li>Driver initialization<\/li>\n\n\n\n<li>Wait setup<\/li>\n\n\n\n<li>Common utilities<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-223\" style=\"color:#ff8d00\"><strong>220. What are reusable methods in POM?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Methods that can be used multiple times across tests.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">click()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">sendKeys()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">selectDropdown()<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-224\" style=\"color:#ff8d00\"><strong>221. How is POM useful in large projects?<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In large projects:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>UI changes happen frequently<\/li>\n\n\n\n<li>Multiple testers work together<\/li>\n\n\n\n<li>Reusable components are needed<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">POM helps manage all these efficiently.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-225\" style=\"color:#ff8d00\"><strong>222. Explain real-time usage of POM.<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In real projects:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Every page has separate class<\/li>\n\n\n\n<li>Test cases call page methods<\/li>\n\n\n\n<li>Framework becomes modular and scalable<\/li>\n\n\n\n<li>Maintenance becomes easier when UI changes occur<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-226\" style=\"color:#ff8d00\"><strong>223. What is Log4j?<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Log4j is a Java-based logging framework used to generate application logs for debugging, monitoring, and troubleshooting.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-227\" style=\"color:#ff8d00\"><strong>224. Why is logging important in automation testing?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Logging helps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Track test execution<\/li>\n\n\n\n<li>Identify failures<\/li>\n\n\n\n<li>Debug issues easily<\/li>\n\n\n\n<li>Monitor application behavior<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-228\" style=\"color:#ff8d00\"><strong>225. What are the main components of Log4j?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Logger<\/li>\n\n\n\n<li>Appender<\/li>\n\n\n\n<li>Layout<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-229\" style=\"color:#ff8d00\"><strong>226. What is a Logger in Log4j?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Logger is used to capture logging information in the application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Logger log = Logger.getLogger(Test.class);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-230\" style=\"color:#ff8d00\"><strong>227. What is an Appender?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Appender decides where logs will be stored.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ConsoleAppender<\/li>\n\n\n\n<li>FileAppender<\/li>\n\n\n\n<li>RollingFileAppender<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-231\" style=\"color:#ff8d00\"><strong>228. What is a Layout in Log4j?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Layout defines the format of log messages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%d &#91;%t] %-5p %c - %m%n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-232\" style=\"color:#ff8d00\"><strong>229. What are the different log levels in Log4j?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Log Level<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td>ALL<\/td><td>Logs everything<\/td><\/tr><tr><td>TRACE<\/td><td>Detailed information<\/td><\/tr><tr><td>DEBUG<\/td><td>Debugging information<\/td><\/tr><tr><td>INFO<\/td><td>General information<\/td><\/tr><tr><td>WARN<\/td><td>Warning messages<\/td><\/tr><tr><td>ERROR<\/td><td>Error messages<\/td><\/tr><tr><td>FATAL<\/td><td>Critical errors<\/td><\/tr><tr><td>OFF<\/td><td>Turns off logging<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-233\" style=\"color:#ff8d00\"><strong>230. What is the use of log4j.properties file?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It is used to configure:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log levels<\/li>\n\n\n\n<li>Appenders<\/li>\n\n\n\n<li>Layouts<\/li>\n\n\n\n<li>Log file location<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-234\" style=\"color:#ff8d00\"><strong>231. How do you configure Log4j?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>log4j.rootLogger=INFO, file<br><br>log4j.appender.file=org.apache.log4j.FileAppender<br>log4j.appender.file.File=logs\/application.log<br>log4j.appender.file.layout=org.apache.log4j.PatternLayout<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-235\" style=\"color:#ff8d00\"><strong>231. How do you print logs in Log4j?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>log.info(\"Test Started\");<br>log.error(\"Test Failed\");<br>log.debug(\"Debug Message\");<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-236\" style=\"color:#ff8d00\"><strong>233. What is the difference between INFO and DEBUG?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>INFO \u2192 General execution information<\/li>\n\n\n\n<li>DEBUG \u2192 Detailed debugging information for developers<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-237\" style=\"color:#ff8d00\"><strong>234. What is RollingFileAppender?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It creates new log files when file size reaches a limit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-238\" style=\"color:#ff8d00\"><strong>235. What is the advantage of using RollingFileAppender?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Prevents large log files<\/li>\n\n\n\n<li>Improves log management<\/li>\n\n\n\n<li>Creates backup log files automatically<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-239\" style=\"color:#ff8d00\"><strong>236. What is PatternLayout?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PatternLayout formats log messages in a customizable pattern.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-240\" style=\"color:#ff8d00\"><strong>237. How is Log4j used in Selenium Automation Framework?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Log4j is used to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log test execution steps<\/li>\n\n\n\n<li>Capture pass\/fail status<\/li>\n\n\n\n<li>Store exception details<\/li>\n\n\n\n<li>Debug automation scripts<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-241\" style=\"color:#ff8d00\"><strong>238. How do you integrate Log4j with Selenium?Steps:<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add Log4j dependency<\/li>\n\n\n\n<li>Create log4j.properties file<\/li>\n\n\n\n<li>Configure logger in Java class<\/li>\n\n\n\n<li>Use logging methods<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-242\" style=\"color:#ff8d00\"><strong>239. What dependency is required for Log4j in Maven?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;dependency&gt;<br>    &lt;groupId&gt;log4j&lt;\/groupId&gt;<br>    &lt;artifactId&gt;log4j&lt;\/artifactId&gt;<br>    &lt;version&gt;1.2.17&lt;\/version&gt;<br>&lt;\/dependency&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-243\" style=\"color:#ff8d00\"><strong>240. What is the difference between Log4j and System.out.println()?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Log4j<\/th><th>System.out.println<\/th><\/tr><\/thead><tbody><tr><td>Professional logging<\/td><td>Simple console printing<\/td><\/tr><tr><td>Supports log levels<\/td><td>No log levels<\/td><\/tr><tr><td>Can store logs in files<\/td><td>Only console output<\/td><\/tr><tr><td>Better for frameworks<\/td><td>Not suitable for large projects<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-244\" style=\"color:#ff8d00\"><strong>241. What is Root Logger?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Root Logger is the default logger that controls all child loggers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>log4j.rootLogger=DEBUG, console<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color has-medium-font-size wp-elements-245\" style=\"color:#ff8d00\"><strong>242. What is the difference between Log4j1 and Log4j2?<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log4j2 is faster<\/li>\n\n\n\n<li>Better performance<\/li>\n\n\n\n<li>Supports asynchronous logging<\/li>\n\n\n\n<li>Improved security<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Top Java Selenium Interview Questions &amp; Answers 1. What is Java? Java is a high-level, object-oriented, platform-independent programming language used for developing web, desktop, mobile, and automation applications. 2. What are the features of Java? 3. What are variables in Java? Variables are containers used to store data values. Example: 4. What are data types &#8230; <a title=\"Java Selenium Interview Questions and Answers\" class=\"read-more\" href=\"https:\/\/logicnextgen.com\/tutorials\/java-selenium-interview-questions-and-answers\/\" aria-label=\"Read more about Java Selenium Interview Questions and Answers\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1243","page","type-page","status-publish"],"_links":{"self":[{"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/pages\/1243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/comments?post=1243"}],"version-history":[{"count":35,"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/pages\/1243\/revisions"}],"predecessor-version":[{"id":1338,"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/pages\/1243\/revisions\/1338"}],"wp:attachment":[{"href":"https:\/\/logicnextgen.com\/tutorials\/wp-json\/wp\/v2\/media?parent=1243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}