Driver Service Class
The Service classes are for managing the starting and stopping of drivers. They can not be used with a Remote WebDriver session.
Service classes allow you to specify information about the driver, like location and which port to use. They also let you specify what arguments get passed to the command line. Most of the useful arguments are related to logging.
Default Service instance
To start a driver with a default service instance:
import org.openqa.selenium.remote.service.DriverService;
from selenium.webdriver.chrome.service import Service as ChromeService
[TestMethod]
public void BasicService()
Driver location
Note: If you are using Selenium 4.6 or greater, you shouldn’t need to set a driver location. If you can not update Selenium or have an advanced use case here is how to specify the driver location:
driver_path = os.getenv('CHROMEWEBDRIVER') + 'chromedriver'
Driver port
If you want the driver to run on a specific port, you may specify it as follows:
public void setDriverLocation() {
Logging
Logging functionality varies between browsers. Most browsers allow you to specify location and level of logs. Take a look at the respective browser page: