How does Selenium interact with the browser?

What is Selenium?

Selenium is an open source library which is used to interact with browsers. It provides various APIs to perform actions on a web page elements, e.g. clicking, selection from dropdown, entering texts in textboxes, navigating and a lot more. (It can not be used for desktop apps)

💡
Selenium doesn't provide any methods/libraries to validate a testcase. It is just a library used to interact with browser components. TestNG, JUnit and other such libraries are used along with Selenium to validate/assert testcases.

Supporting browsers and languages:

It supports all major browsers like : Chrome, Firefox, Edge, Safari, Opera.
It supports programming languages like : Java, Python, Java Script, Ruby, C# etc.

What is a driver?

Selenium provides the WebDriver API which contains the necessary methods to launch a browser natively and perform actions. But to be able to communicate with the browser, WebDriver needs a driver. A driver is specific to each browser. The browser vendors are responsible to provide their own browser drivers( chromedriver, geckodriver, msedgedriver, etc)

When I say, WebDriver launches a browser natively, that means it will launch the browser locally on our system. Although Selenium provides a powerful feature that is Selenium Grid, which is used to run the script remotely. It can help in running tests in parallel on different servers, different browsers at once!

Please read the official documentation to know more : https://www.selenium.dev/documentation/overview/components/
https://www.selenium.dev/documentation/webdriver/