Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Java Selenium / HtmlunitDriver opens wrong website

I try to open a website by using `driver.get(url):

    driver = new HtmlUnitDriver(BrowserVersion.CHROME);
    driver.setJavascriptEnabled(true);
    driver.setAcceptSslCertificates(true);
    driver.setDownloadImages(true);

    driver.get(<private url>);

However, the URL contains an 'Ö', a german Umlaut. So the driver replaces 'ö' with '%D6'

So it opens a wrong site.

I tried changing to UTF-8 in Eclipse; didn't work.

Also using unicode didn't work.

Does anyone have an idea?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your case works with 2.27-SNAPSHOT.

indexÖ.html:

<body>Ö</body>

Java code:

    WebDriver driver = new HtmlUnitDriver();
    driver.get("http://localhost:8080/indexÖ.html");
    System.out.println(driver.getPageSource());

Output:

<?xml version="1.0" encoding="ISO-8859-1"?>
<html>
  <head/>
  <body>
    Ã
  </body>
</html>

which is what real Chrome also shows.

As you said, ensure your all workspace is in UTF-8: enter image description here

And if you are using maven:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!