---Advertisement---

Automation Testing Interview Questions and Answers (Level-3)

By Manisha

Published On:

---Advertisement---

 101. Difference between quit() & close() in Selenium

  • driver.quit(): Closes all browser windows opened by Selenium and ends the WebDriver session.
  • driver.close(): Closes only the current active browser window

🔹 102. How to Maximize & Minimize the Browser in Selenium WebDriver

// Maximize

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

// Minimize

 driver.manage().window().minimize();


🔹 103. What is WebDriver – Interface or Class?

WebDriver is an interface provided by Selenium that represents the core methods used to automate browsers. Classes like ChromeDriver, FirefoxDriver implement this interface.


🔹 104. What is the Super Interface of WebDriver?

The SearchContext interface is the super interface of WebDriver. It contains the basic methods: findElement() and findElements().


🔹 105. What is WebElement & Methods in Selenium?

WebElement represents HTML elements. It has several methods like:

  • click()
  • sendKeys()
  • getText()
  • getAttribute()
  • isDisplayed()
  • isEnabled()
  • isSelected()

🔹 106. How Many Locators in Selenium? Which One is Preferred?

Selenium has 8 locators:

  • id
  • name
  • className
  • tagName
  • linkText
  • partialLinkText
  • xpath
  • cssSelector

Preferred: id for speed and reliability.


🔹 107. How to Check Whether Object is Present in GUI?

boolean isPresent = driver.findElements(By.id(“elementId”)).size() > 0;


🔹 108. How to Check Text from the UI?

String text = driver.findElement(By.id(“elementId”)).getText();


🔹 109. How to Capture Element Color, Height, Width, Font-size?

String color = element.getCssValue(“color”);

String height = element.getCssValue(“height”);

String width = element.getCssValue(“width”);

String fontSize = element.getCssValue(“font-size”);


🔹 110. How to Get the Location of a WebElement?

Point location = element.getLocation();

int x = location.getX();

int y = location.getY();


🔹 111. How to Check if Object is Selected?

boolean selected = element.isSelected();


🔹 112. How to Check if Object is Enabled?

boolean enabled = element.isEnabled();


🔹 113. How to Delete All Cookies in WebDriver?

driver.manage().deleteAllCookies();


🔹 114. Do We Use Constructors in WebDriver?

No. We don’t define custom constructors in WebDriver usage. But internally, the driver classes like ChromeDriver have constructors.


🔹 115. How to Compare Two Images in Selenium?

Use OpenCV, Sikuli, or BufferedImage class in Java for pixel-by-pixel image comparison.


🔹 116. How to Get WebElement Height and Width?

Dimension size = element.getSize();

int height = size.getHeight();

int width = size.getWidth();


🔹 117. What is Synchronization in Selenium?

Synchronization is the process of matching the execution speed of Selenium with the application’s load time. It avoids ElementNotVisibleException.


🔹 118. How to Handle Synchronization in Selenium?

Using different wait mechanisms:

  • Implicit Wait
  • Explicit Wait
  • Fluent Wait
  • Thread.sleep (not recommended)

🔹 119. Which Wait is Used for Page Load?

driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);


🔹 120. How to Handle Dynamic Objects?

Strategies:

  • Use dynamic XPath
  • Wait for element visibility
  • Use contains(), starts-with() functions

👉The Next 20 Questions-IV: AUTOMATION TESTING
👉The Next 15 Questions-V: AUTOMATION TESTING

---Advertisement---

Leave a Comment