Prev Next

Testing / Selenium Interview questions

Explain the internal working of Selenium WebDriver?

When test code calls a WebDriver method, the language binding serializes it into an HTTP request following the W3C WebDriver protocol and sends it to a locally running driver executable (ChromeDriver, GeckoDriver, etc.) over a local port.

sequenceDiagram
    participant T as Test Script
    participant C as Client Binding
    participant D as Driver Executable
    participant B as Browser
    T->>C: driver.findElement(By.id(...))
    C->>D: HTTP request (W3C WebDriver JSON)
    D->>B: Native browser automation command
    B-->>D: Result
    D-->>C: HTTP response (JSON)
    C-->>T: WebElement / value

The driver executable is what actually knows how to talk to that specific browser's native automation hooks - for ChromeDriver, this is built on the Chrome DevTools Protocol internally, translated into and out of the standardized WebDriver JSON format so the same client code works regardless of which browser is on the other end. This driver-executable layer is exactly what Selenium 4's client libraries and Selenium Grid both build on top of.

A WebDriver command from test code is first serialized as:
The driver executable's role is to:

More Related questions...

What is Selenium? What are the components of the Selenium suite? What are the supported browsers in Selenium? What are the supported programming languages in Selenium WebDriver? How do you install Selenium WebDriver in a Java project? What is Selenium WebDriver? What are locators in Selenium? How do you use the By class in Selenium? Define implicit wait in Selenium? Describe the Selenium IDE? List the different types of waits in Selenium? How do you take a screenshot in Selenium WebDriver? What is a WebElement in Selenium? How do you launch a browser using Selenium WebDriver? What are assertions in Selenium? What is the difference between findElement and findElements in Selenium? How does Selenium handle multiple windows and tabs? What is the difference between driver.close() and driver.quit()? How do you handle iframes in Selenium? What is the difference between implicit wait and explicit wait? How does Selenium's WebDriverWait work with ExpectedConditions? What is the purpose of Selenium Grid? How do you handle dropdowns in Selenium using the Select class? What is the difference between XPath and CSS selectors? How do you run tests in parallel using TestNG and Selenium? What is the difference between @BeforeMethod and @BeforeClass in TestNG? How do you handle file uploads in Selenium? How do you handle browser cookies in Selenium? What is the difference between Thread.sleep() and WebDriverWait? How do you generate test reports in Selenium (e.g., with ExtentReports)? What is the difference between headless and headed mode in Selenium? How do you debug a failing Selenium test? What is the JavascriptExecutor in Selenium? How do you handle dynamic web elements in Selenium? What is the difference between Selenium's Actions class and native WebElement methods? Explain the internal working of Selenium WebDriver? Explain the execution flow of a Selenium test? Why did Selenium 4 move to the W3C WebDriver protocol? When should you use Selenium Grid over local execution? How can you optimize Selenium test execution time? How do you troubleshoot a StaleElementReferenceException in Selenium? Explain the architecture of Selenium Grid 4? What happens when a Selenium locator doesn't match any element? How does Selenium implement browser automation without a built-in interception mechanism (network mocking limitations)? Why doesn't Selenium provide auto-waiting like modern frameworks? How do you implement the Page Object Model with PageFactory in Selenium? What is the difference between Selenium Grid's Hub-Node model and the new Router-Distributor model? How does Selenium handle elements inside Shadow DOM? Explain the internal working of Selenium's explicit wait polling mechanism? How can you integrate Selenium tests into a CI/CD pipeline?
Show more question and Answers...

API

Comments & Discussions