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
Q1: How to launch different browsers?
// 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 completionnavigate().to()
: Does the same but maintains browser history
Q3: Navigation commands
driver.navigate().back(); driver.navigate().forward(); driver.navigate().refresh();
Q4: close() vs quit()
close()
: Closes current windowquit()
: Closes all windows and ends session
Q5: Handling dropdowns
Select select = new Select(driver.findElement(By.id("dropdown"))); select.selectByVisibleText("Option");
2. Actions Class Questions
Q6: Mouse hover implementation
Actions actions = new Actions(driver); actions.moveToElement(element).perform();
Q7: Drag and drop
actions.dragAndDrop(source, target).perform();
Q8: Right-click and double-click
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 elementfindElements()
: Returns list of all matching elements
Q11: XPath types
Absolute:
/html/body/div
Relative:
//div[@class='example']
4. Window/Frames Handling
Q12: Switching windows
for (String handle : driver.getWindowHandles()) { driver.switchTo().window(handle); }
Q13: Handling iframes
driver.switchTo().frame("frameName");
5. Advanced Concepts
Q14: Handling dynamic elements
Use Explicit Waits:
new WebDriverWait(driver, 10) .until(ExpectedConditions.visibilityOfElementLocated(By.id("dynamic")));
Q15: Taking screenshots
File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenshot, new File("screenshot.png"));
Q16: Handling file uploads
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.
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.
ReplyDeleteSelenium Certification Training in Electronic City
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
ReplyDeleteCracking The Coding Interview
data structures and algorithms
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.
ReplyDeleteI 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
ReplyDeleteThe cost of an Insurance Policy for your family would be about $12,000. What Is The Cost Of Vyvanse Without Insurance
ReplyDelete
ReplyDeletePlease keep sharing more and more wonderful articles.