Search code examples
javaeclipseselenium-webdrivercharacter-encoding

Cannot use some special characters in Eclipse


I am trying to automate functional testing using Selenium webdriver and Java. There is table showing bank account name and account balance in the AUT. Account name, currency symbol and account balance is showing in a single cell (eg: Savings-Account ₹ 10000). I can read these details using

List<String> tableData=new ArrayList();
List<WebElement> elements=new ArrayList();
elements=driver.findElements(By.xpath(".//[@id='account_list_table']"));
for(WebElement el:elements)
tableData=el.getText();

But the issue is that the result contains currency symbol also. I need to remove the currency symbol from the result. So I tried

List<String> accountDetails=new ArrayList();
for(String s:tableData)
accountDetails.add(s.replaceAll("₹"));

But eclipse shows an error

(Save could not be competed. Try File>Save As...if the problem presists. Reson: Some characters can not be mapped using "Cp1252" character encoding. Either change the encoding or remove the characters which are not supported by the "Cp1252" character encoding)

I can not replace all the special characters from the string 'accountDetails' since the account name name may contains special characters


Solution

  • Try change Text file encoding of eclipse: Window -> Preferences -> General -> Workspace In Text file encoding, choose Other UTF-8.