What does selenium chromeDriver's port mean?

6.4k views Asked by At

When all ports are open, you can use the Selenium ChromeDriver to collect the ports. However, as per company policy, only ports 53,443,80 are open. I can't run it when doing web collection using Selenium ChromeDriver. Checking the execution log, a certain random port is used. I found a way to manually configure that port. After manually setting the port to 4444, I added 4444 to the firewall port and it doesn't run on startup. What is the purpose of this port?

Is it possible to collect the web using the Selenium ChromeDriver by opening only ports 53, 443, 80 on the private network?

Please tell me a site where you can find a list of options related to Selenium and ChromeDriver execution, processes, structure, etc.

Below are my ChromeDriver options.

ChromeOptions options = new ChromeOptions();
            options.addArguments("--headless");
            options.setHeadless( _configInfo._driverHeadLess );
            options.addArguments("--disable-notifications");
            options.addArguments("--disable-push_messaging");
            options.addArguments("--disable-extensions");
            options.addArguments("--disable-cookies");
            options.addArguments("--disable-plugins");
            options.addArguments("--disable-mouselock");
            
            options.addArguments("--disable-media_stream");
            options.addArguments("--disable-media_stream_mic");
            options.addArguments("--disable-media_stream_camera");
            
            options.addArguments("--disable-ppapi_broker");
            options.addArguments("--disable-automatic_downloads");
            options.addArguments("--disable-midi_sysex");
            options.addArguments("--disable-metro_switch_to_desktop");
            options.addArguments("--disable-protected_media_identifier");
            options.addArguments("--disable-app_banner");
            options.addArguments("--disable-site_engagement");
            options.addArguments("--disable-durable_storage");
            options.addArguments("--whitelisted-ips");
            //options.addArguments("--single-process");
            //options.addArguments("--disable-dev-shm-usage");
            //options.addArguments("--no-sandbox");
ChromeDriverService service = new ChromeDriverService.Builder().usingDriverExecutable(new 
                                   File("/lib/chromedriver")).usingPort(4444).build();
service.start();
WebDriver _driver = new RemoteWebDriver(service.getUrl(),options);
1

There are 1 answers

11
PDHide On BEST ANSWER

Chrome driver starts a server and exposes this server on the port specified.

So when you start the test, you talk to the server by talking to the exposed API (that's what APIs are for)

The driver server in turn talks to the browser through other protocols (used to be JSON wire protocol, now uses W3 protocol) And does what we requested

enter image description here

https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/remote/service/DriverService.Builder.html#usingPort(int)

https://www.selenium.dev/documentation/en/webdriver/understanding_the_components/