Home > Net >  HtmlUnitDriver no need to load page
HtmlUnitDriver no need to load page

Time:04-07

I am writing a test that should get only the URL from the redirect, there is no need to load the non-existing page. Every time I get this exception:

java.lang.RuntimeException: java.net.UnknownHostException: No such host is known (bank.test.com)

How I said, there is no need to load only what I need is to get the URL when a user submits the form, how should I do it?

This is the code where it is causing exception:

@Step("Sign in")
    public static String signIn(WebDriver driver, String url, String username, String password) {
        driver.get(url);

        HtmlUnitDriverSteps.setFieldValueByName(driver, USERNAME, username);
        HtmlUnitDriverSteps.setFieldValueByName(driver, PASSWORD, password   Keys.ENTER);
        
        return driver.getCurrentUrl();
    }

Is there solution for my issue?

CodePudding user response:

Instead of the partial url_string bank.test.com you need to pass the complete (fully qualified) url_string as follows:

https://bank.test.com

CodePudding user response:

UnknownHostException: No such host is known

This usually point to some problems resolving the URL into an ip address to connect to. Please check if this url is available from your browser. Maybe there is a proxy configured for your browser.

  • Related