I need to execute various selenium tests with the same code on different IPs and different machines (that's a requirement, so I cannot use cloud), so I decided to convert my laptop into selenium hub-server and ask clients to have a selenium node running on their machines with ngrok tunnel.
I have a Selenium hub on my laptop that is started java -jar "selenium-server-4.0.0.jar" hub on localhost:4444. To access it from outside, I used ngrok to forward three ports: 4442, 4443, 4444.
Now I start a node on a different pc in different network, with ngrok tunnel running at port 80 (otherwise there will be problems with connection) java -jar "selenium-server-4.0.0.jar" node --detect-drivers true --publish-events tcp://firsturl.tcp.ngrok.io:4442 --subscribe-events tcp://secondurl.tcp.ngrok.io:4443 --host urlOfNode.ngrok.io --port 80. The node is successfully connected. Now I attempt to run java code from my laptop
URL url = new URL("https://randomlygeneratedurl.ngrok.io/wd/hub");
ChromeOptions options = new ChromeOptions();
options.setHeadless(false);
options.setExperimentalOption("excludeSwitches", new String[] { "enable-automation" });
options.addArguments("--start-maximized");
options.addArguments("--disable-gpu");
options.addArguments("--whitelisted-ips=''");
options.addArguments(
"user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36");
WebDriver driver = new RemoteWebDriver(url, options);
driver.get("https://www.google.com");
This code successfully starts chrome on a different machine with certain parameters (like exclude switches and maximized), however in url bar I get 'data:,' and on the line of driver.get() I receive an exception
Exception in thread "main" org.openqa.selenium.json.JsonException: Unable to determine type from: R. Last 1 characters read: R
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'
System info: host: 'HOST', ip: 'IP', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '10.0.2'
Driver info: driver.version: RemoteWebDriver`
When I don't use the iptunnels, everything work just fine. I thought that it may be because of networking, like hub assignes a node an internal ip address, however after examining /status it doesn't seem to be the case. I fear that if I use a VPN between node and hub, all machines will have a similar IP, and that's exactly what I try to avoid. Plus, selenium docs say that Selenium Grid 4 allows huge flexibility.