Selenium navigate().to() stuck without error

482 Views Asked by At

I am running tests using TestNG, chromium and Selenium, in Java, on two machines:

  • my own laptop
  • a Mac Mini I do not have physical access to, that I connect via SSH, that has the same identical project structure as the project on my laptop.

Both machines operate behind the same corporate proxy.

The issue I am having is the following:

  • while the tests run smoothly on my machine, when I execute the command to start them on the Mac Mini, the execution stops when telling the Selenium WebDriver to navigate to any specified url using driver.navigate().to(url) or driver.get(url); causing the program to freeze without throwing any exception, essentially remaining on hold.

The code resembles the following:

  • in the @BeforeClass beforeClass() driver is initialized with an instance of ChromeDriver using ChromeOptions. Among other settings, I add the following arguments to the ChromeOptions like such chromeOptions.addArguments(options): where options is things like --disable-web-security, --allow-running-insecure-content, --allow-insecure-localhost and most importantly: --proxy-server=address:port (e.g. --proxy-server=172.26.44.146:3128).

  • in the @BeforeMethod beforeMethod() after checking that the driver is not null and that the URL url is a valid one, I execute something similar to the stylized following code:

try {
        log.debug("Navigating to: " + url);
        driver.navigate().to(url);
        log.debug("Navigated to url: " + driver.getCurrentUrl());

} catch (Exception e) {
        log.error("Unable to navigate at page: " + url.toString());
        throw e;
} 

As I said, when running the test on the Mac Mini via SSH using the command line in a similar fashion to: java -cp WORKSPACE org.testng.TestNG testng.xml the code stops executing and freezes at log.debug("Navigating to: " + url); essentially not producing other output and forcing me to manually stop the execution of the test.

As additional information, tests are run using chromium version 72.0.3609.0. The ChromeOptions also receive the following proxy setting (like such: chromeOptions.setProxy(p);) where p is a Proxy with

p.setProxyType(ProxyType.MANUAL);
p.setAutodetect(false);

I suspect an issue with the proxy (and am doubtful I have correctly preconfigured the program), but, quite frankly, I am puzzled by the fact that the same script runs locally on my machine and is unable to run locally on the Mac Mini when the tests are launched via SSH.

0

There are 0 best solutions below