I use selenium version: '3.141.59' to access the content of a page with java, I am using the ChromeDriver to emulate the use of a web browser, my problem occurs when the query url contains special characters --charset=utf -8 since it decodes the character and the result of the web request is not as expected, this is a code example:
System.setProperty(
"webdriver.chrome.driver",
"C:\\Program Files\\Controllers\\chromedriver-win64\\chromedriver.exe"
); // -> chromedriver version 115.0.5790.102
ChromeOptions options = new ChromeOptions();
options.addArguments("--charset=UTF-8");
WebDriver driver = new ChromeDriver(options);
driver.get("úrl/example/with/especial-character/"); // -> url: https://www.úrl/example/with/especial-character/
I have tried encoding the url using:
String encoderUrl = URLEncoder.encode("úrl/example/with/especial-character/", "UTF-8");
driver.get(encodeUrl)
But this modifies the url which is already encoded, so I'm out of ideas how to solve this, any useful method or library to solve this?
dependencies {
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver
implementation group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: '3.141.59'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support
implementation group: 'org.seleniumhq.selenium', name: 'selenium-support', version: '3.4.0'
}