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.

    Comments

    1. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

      Selenium Certification Training in Electronic City

      ReplyDelete
    2. Thank you for sharing such a useful article. I had a great time. This article was fantastic to read. Continue to publish more articles on
      Cracking The Coding Interview
      data structures and algorithms

      ReplyDelete
    3. Thanks for publishing such great information. You are doing such a great job. This information is very helpful for everyone. Keep sharing about Website Development Service Provider. Thanks.

      ReplyDelete
    4. I sincerely believe that a day will come when every big decision and life changing events will originate from our sucessful use of Internet. etvbharat com

      ReplyDelete
    5. The cost of an Insurance Policy for your family would be about $12,000. What Is The Cost Of Vyvanse Without Insurance

      ReplyDelete

    6. Please keep sharing more and more wonderful articles.

      ReplyDelete

    Post a Comment

    Popular posts from this blog

    Selenium Automation for E-commerce Websites

    Top 10 Demo Websites for Selenium Automation Practice

    Mastering Selenium Practice: Automating Web Tables with Demo Examples

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

    Top 10 Highest Paid Indian-Origin CEOs in the USA: Leaders Shaping Industries

    14 Best Selenium Exercises to Master Automation Testing Skills

    Best Budget Tech Gadgets You Can Buy in 2025

    Understanding Cryptocurrency: A Beginner's Guide to Bitcoin and Ethereum

    How to Automate Google Search with Selenium WebDriver

    Top 8 AI Tools You Should Start Using Today