Top 20 Selenium Interview Questions & Answers

Prepare for your Selenium automation interview with these carefully curated questions covering basic to advanced concepts.

Table of Contents

  1. Basic Selenium Questions

  2. Actions Class Questions

  3. Locators Questions

  4. Window/Frames Handling

  5. Advanced Concepts

  6. Framework & OOPS


1. Basic Selenium Questions

Q1: How to launch different browsers?

java

// Chrome
WebDriver driver = new ChromeDriver();

// Firefox
WebDriver driver = new FirefoxDriver();

// Edge
WebDriver driver = new EdgeDriver();

Q2: Difference between get() and navigate().to()

  • get(): Loads a new page and waits for completion

  • navigate().to(): Does the same but maintains browser history

Q3: Navigation commands

java

driver.navigate().back();
driver.navigate().forward();
driver.navigate().refresh();

Q4: close() vs quit()

  • close(): Closes current window

  • quit(): Closes all windows and ends session

Q5: Handling dropdowns

java

Select select = new Select(driver.findElement(By.id("dropdown")));
select.selectByVisibleText("Option");

2. Actions Class Questions

Q6: Mouse hover implementation

java

Actions actions = new Actions(driver);
actions.moveToElement(element).perform();

Q7: Drag and drop

java

actions.dragAndDrop(source, target).perform();

Q8: Right-click and double-click

java

actions.contextClick(element).perform();  // Right-click
actions.doubleClick(element).perform();  // Double-click

3. Locators Questions

Q9: Locator types

8 types: ID, Name, ClassName, TagName, LinkText, PartialLinkText, CSS, XPath

Q10: findElement() vs findElements()

  • findElement(): Returns first matching element

  • findElements(): Returns list of all matching elements

Q11: XPath types

  • Absolute: /html/body/div

  • Relative: //div[@class='example']


4. Window/Frames Handling

Q12: Switching windows

java

for (String handle : driver.getWindowHandles()) {
    driver.switchTo().window(handle);
}

Q13: Handling iframes

java

driver.switchTo().frame("frameName");

5. Advanced Concepts

Q14: Handling dynamic elements

Use Explicit Waits:

java

new WebDriverWait(driver, 10)
    .until(ExpectedConditions.visibilityOfElementLocated(By.id("dynamic")));

Q15: Taking screenshots

java

File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new File("screenshot.png"));

Q16: Handling file uploads

java

driver.findElement(By.id("upload")).sendKeys("file_path");

6. Framework & OOPS

Q17: Common framework types

  • Data-Driven

  • Keyword-Driven

  • Hybrid

  • POM (Page Object Model)

Q18: OOPS in Selenium

Key concepts:

  • Encapsulation (Page Objects)

  • Inheritance (BaseTest classes)

  • Polymorphism (Method overloading)

Q19: CI/CD Integration

Popular tools:

  • Jenkins

  • GitHub Actions

  • Azure DevOps

Q20: How to handle Captcha?

Captcha can't be handled with Selenium. CAPTCHAs are specifically designed to prevent automated interactions. The dev team can be asked to disable it on Dev/QA environments.


Pro Tip: Focus on practical implementation rather than theoretical definitions during interviews.

    Popular posts from this blog

    Mastering Regression Testing: Best Practices, Tools, and Techniques

    A Complete Guide to Cross-Browser Testing Strategies

    Top 11 Interview Blunders That Can Cost You the Job: Expert Tips to Avoid Them

    Understanding Classes in Python: Everything About Classes and Attributes

    Best Budget Tech Gadgets You Can Buy in 2025

    Mastering VBA with Excel: A Comprehensive Guide to Automating Tasks and Enhancing Functionality

    AI for Beginners: Definition, Tools & Real-World Examples

    25+ Selenium WebDriver Commands: The Complete Cheat Sheet with Examples

    Trump Media’s $3 Billion Crypto Investment Plan: A Bold Vision for the Digital Future

    Exploring Software Testing Methods: Black Box, White Box, Gray Box, Exploratory and Ad-Hoc Testing