Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

137
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda