0

I've been looking at the distinction between webDriver.naviagate.to and webDriver.get and they seem the same.

Certainly a web page launches..but then a big nothing burger. Not sure where to start to even figure out what's happening or why.

slow-motion crash:

thufir@dur:~/NetBeansProjects/scrape$ 
thufir@dur:~/NetBeansProjects/scrape$ gradle run

> Task :run
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting 45 seconds for Firefox to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'dur', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.18.0-25-generic', java.version: '12.0.1'
Driver info: driver.version: FirefoxDriver
        at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:247)
        at org.openqa.selenium.firefox.XpiDriverService.start(XpiDriverService.java:159)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
        at net.bounceme.dur.scrape.Scrape.initWebDriver(Scrape.java:37)
        at net.bounceme.dur.scrape.App.runApp(App.java:28)
        at net.bounceme.dur.scrape.App.main(App.java:18)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:9070/hub/status] to be available after 45010 ms
        at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
        at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:245)
        ... 10 more
Caused by: java.util.concurrent.TimeoutException
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)
        at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156)
        at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
        ... 11 more

> Task :run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/home/thufir/.sdkman/candidates/java/12.0.1-zulu/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 48s
3 actionable tasks: 1 executed, 2 up-to-date
thufir@dur:~/NetBeansProjects/scrape$ 

code:

package net.bounceme.dur.scrape;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import java.util.logging.Logger;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import org.basex.core.Context;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Scrape {

    private static final Logger LOG = Logger.getLogger(Scrape.class.getName());
    private Properties properties = new Properties();
    private Properties systemProperties = new Properties();
    private final Context context = new Context();
    private WebDriver webDriver = null;

    private Scrape() {
        // needs a properties file for configuration
    }

    public Scrape(Properties properties) {
        this.properties = properties;
        LOG.fine(properties.toString());
    }

    public void initWebDriver() throws MalformedURLException {
        Path path = FileSystems.getDefault().getPath(properties.getProperty("gecko_path"));
        String webdriver = properties.getProperty("webdriver");
        URL url = new URL(properties.getProperty("url"));
        LOG.fine(path.toString());
        System.setProperty(webdriver, path.toString());
        LOG.fine(System.getProperties().toString());
        webDriver = new FirefoxDriver();
        webDriver.get(url.toString());
        LOG.info(url.toString());
    }

}
  • 1
    I would check those 3: properties file, geckodriver vs firefox version and last but not least - older java version. – Moro Oct 14 at 8:47
1

runs fine with chromium:

thufir@dur:~/NetBeansProjects/scrape$ 
thufir@dur:~/NetBeansProjects/scrape$ gradle run

> Task :run
Starting ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770@{#1003}) on port 25016
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Oct. 12, 2019 11:24:13 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Oct. 12, 2019 11:24:15 P.M. net.bounceme.dur.scrape.Scrape initWebDriver
INFO: ToolsQA – Demo Website to Practice Automation – Demo Website to Practice Automation

BUILD SUCCESSFUL in 6s
3 actionable tasks: 1 executed, 2 up-to-date
thufir@dur:~/NetBeansProjects/scrape$ 

relevant method with chromium config:

    public void initWebDriver() throws MalformedURLException {
        Path path = FileSystems.getDefault().getPath(properties.getProperty("chromium_path"));
        String webdriver = properties.getProperty("chromium_webdriver");
        URL url = new URL(properties.getProperty("url"));
        LOG.fine(path.toString());
        System.setProperty(webdriver, path.toString());
        LOG.fine(System.getProperties().toString());
        webDriver = new ChromeDriver();
        webDriver.get(url.toString());
        LOG.info(webDriver.getTitle());
        webDriver.quit();
    }

more of a work-around than solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.