Selenium GeckoDriver gets the IP and port number of the running driver instance

I am using Selenium 3.4, Geckodriver 0.17.
I am running FirefoxDriver using the code below

    System.setProperty("webdriver.gecko.driver", "geckodriver.exe");
    FirefoxDriver driver = new FirefoxDriver();
    driver.get("http://www.bing.com");
    System.out.println(driver.getSessionId());

Is there a way to get the IP address and port of a running driver instance?

The data I want is printed in magazines.

1499170600204   geckodriver INFO    Listening on 127.0.0.1:38840
1499170601127   geckodriver::marionette INFO    Starting browser C:\Program Files\Mozilla Firefox\firefox.exe with args ["-marionette"]
[GFX1]: Potential driver version mismatch ignored due to missing DLLs igd10umd32 v= and igd10iumd32 v=
1499170608388   Marionette  INFO    Listening on port 12793
Jul 04, 2017 5:46:48 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C

The first line of output 127.0.0.1{8840 prints the information I want. I do not want to analyze the log, because I will run the drivers in parallel.

0
source share
1 answer

RemoteWebDriver has a getCommandExecutormethod.

What type is TypeCasted to HttpCommandExecutorand getAddressOfRemoteServer()returns a URL.

HttpCommandExecutor ce = (HttpCommandExecutor) driver.getCommandExecutor();
System.out.println(ce.getAddressOfRemoteServer());
0

Source: https://habr.com/ru/post/1680962/


All Articles