简体   繁体   English

使用 Selenium Java 获取特殊字符(中文,日文)但给出?

[英]Using Selenium Java get special characters (Chinese, Japanese) but gives?

I have a requirement where I would like to read combination of English and non English characters from a dropdown on Web UI Example- abcd, efgh, 你好, こんにちは我有一个要求,我想从 Web UI 示例的下拉列表中读取英文和非英文字符的组合 - abcd、efgh、你好、こんにちは

public void test(){
    dropdown.click();
    Select newValues = new Select(dropdown);
    List<WebElement> listNewValues  = countryValues.getOptions();
    ArrayList<String> actualDropDownItems = new ArrayList();
    for(WebElement value : listNewValues){
        actualDropDownItems.add(value.getText());
        System.out.println(value.getText().toString());
        }

If I try to run and print this, I get??如果我尝试运行并打印它,我会得到?? for Chinese and Japanese values.对于中国和日本的价值观。 Please note I have read some of the previous suggestions and in eclipse at project> properties level> Resource> Other is set to UTF-8.请注意我已经阅读了之前的一些建议,并且在 eclipse 中的项目>属性级别>资源>其他设置为 UTF-8。 Everywhere it is suggested to use UTF-8.到处都建议使用 UTF-8。 But what else can I do If I have already set this at project properties level.但是如果我已经在项目属性级别设置了它,我还能做什么。

Is there any other easier way of getting this non-English characters?有没有其他更简单的方法来获取这个非英文字符? Any help is appreciated.任何帮助表示赞赏。

PS I had also tried using BufferedWriter approach, but it gives me å›½æ—¥æœ¬ëŒ€í•œë¯¼êµ instead of 你好, こんにちはPS 我也尝试过使用 BufferedWriter 方法,但它给了我 å›½æ—¥æœ¬ëŒ€í•œë¯¼êµ 而不是你好,こんにちは

Running simple System.out.println("你好");运行简单 System.out.println("你好"); was not giving me correct output on Eclipse console.在 Eclipse 控制台上没有给我正确的 output 。 Looks like setting eclipse at project level was not doing anything to help me.看起来在项目级别设置 eclipse 对我没有任何帮助。 project> properties level> Resource> Other is set to UTF-8项目>属性级别>资源>其他设置为UTF-8

Did right click on test, Coverage As> Coverage configuration > Common and then set Other to UTF-8, solved my problem.右键单击测试,Coverage As> Coverage configuration > Common 然后将 Other 设置为 UTF-8,解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM