Selenium webdriver unable to read chinese on xpath

2019-07-09 01:10发布

问题:

im facing an issue regarding the xpath trying to get value of chinese characters and return the value was alien value of chinese value. Kindly advise . Indeed i had change the encoding to UTF-8 hence its still not working. I try to set a log on the string Str , as the value of str are "???".

CODE :

String str = new String("三连号".getBytes(), "UTF-8");

WebDriverWait wait = new WebDriverWait(driver, 60);
                element = wait
                        .until(ExpectedConditions.presenceOfElementLocated(By.xpath("//span[@class='content' and contains(text(),'"+str+"')]")));