Javascript 在testdata.properties文件中显示英语以外的语言

Javascript 在testdata.properties文件中显示英语以外的语言,javascript,java,eclipse,selenium,application.properties,Javascript,Java,Eclipse,Selenium,Application.properties,我正在使用testdata.properties文件将值传递到selenium测试脚本中。我进去的时候 Chinese Charachter : 成長促進 japanese Charachter :`へのコミットメント 在testdata.properties文件中,它显示为 chinese charachter :: \u6210\u9577\u4FC3\u9032 japanese charachter :: \u3078\u306E\u30B3\u30DF\u30C3\u30C8\u

我正在使用testdata.properties文件将值传递到selenium测试脚本中。我进去的时候

Chinese Charachter : 成長促進

japanese Charachter :`へのコミットメント
在testdata.properties文件中,它显示为

chinese charachter :: \u6210\u9577\u4FC3\u9032

japanese charachter :: \u3078\u306E\u30B3\u30DF\u30C3\u30C8\u30E1\u30F3\u30C8

请告诉我如何在testdata.properties文件中显示日语文本?

默认编码是eclipse是“ISO 8859-1编码”,因此当您粘贴任何母语代码(如粘贴中文和日语)时,它将默认将其转换为nativeToAscii编码

在eclipse中需要将“ISO 8859-1编码”更改为“UTF-8”

转到Eclipse-Windows-Preferences-搜索内容类型

现在将该编码更改为“UTF-8”,它将以本机语言显示属性文件。首先更新编码,然后应用并关闭

当您设置数据“ISO 8859-1编码”并且使用sendkeys时,它将自动通过本机语言发送数据

请参阅下面的代码片段

package com.software.testing;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.Properties;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Testingclass extends DriverFactory {

    private static WebDriver driver = null;
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        File file = new File("C:\\Users\\eclipse-workspace\\SoftwareTesting\\testdata.properties");
        FileInputStream fileInput = null;
        try {
            fileInput = new FileInputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        Properties prop = new Properties();

        // load properties file
        try {
            prop.load(fileInput);
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Desktop\\ChromeDriver\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.get("http://www.google.com");
        driver.findElement(By.xpath("//input[@title='Search']")).sendKeys(prop.getProperty("japanese"));
        //driver.findElement(By.id("q")).sendKeys(prop.getProperty("chinese"));
    }
}

HI@Dhru'soni-更新到UTF-8后,无法正确读取testdata.properties文件中的以下代码中的值。请帮助我FileInputStream ip=newFileInputStream(System.getProperty(“user.dir”)+“/src/main/java“+”/config/config.properties”);//prop.load(新的InputStreamReader(ip,Charset.forName(“UTF-8”));//prop.load(新的InputStreamReader(ip,字符集forName(“ISO-8859-1”));道具载荷(ip)@arkadiyala您不需要使用//prop.load(新的InputStreamReader(ip,Charset.forName(“UTF-8”));如果您在属性文件中复制测试数据中的数据时设置了编码“ISO 8859-1”,它将以ascii格式存储,但当您使用发送键时,它将自动将其发送到本机语言。你可以参考我的最新答案。嗨@Dhru'soni-谢谢你的帮助。当我设置数据“ISO8859-1编码”时,sendkey通过本机语言发送数据,脚本工作正常,但testdata.properties不是人类可读的格式。是否有任何方法可以同时实现这两个目标(.properties为人类可读格式+senkeys通过本机语言发送数据)