6

I have a problem with the assembly of the project:

D:...\Main.java:112: error: unmappable character (0x98) for encoding windows-1251
robot.getBrowserControl().findElement(By.xpath("//div[.='НАПИСАТЬ']")).click();

This error in line: robot.getBrowserControl().findElement(By.xpath("//div[.='НАПИСАТЬ']")).click();

Images: error, IDEA settings . Ths bottom-right is selected UTF-8. I'm not sure, but maybe it's like the symbol "И"

img errors

This my gradle file

plugins {
    id 'java'
}

group 'ru.grbi3yh.processthesefiles'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

jar {
    baseName = 'ProcessthFiles'
}


apply plugin: 'application'

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.41.0'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
GRbI3yH
  • 105
  • 1
  • 1
  • 8
  • 1
    Have you tried renaming the element, so that it doesn't use special characters? – Geshode Jul 11 '18 at 07:53
  • I would recommend you to not use cyrillic script in the naming of your variables/fields/anything really. You are kinda asking for encoding trouble this way. – Ben Jul 11 '18 at 07:56
  • Guys, that's not the element's name, that's the element's content. – kumesana Jul 11 '18 at 08:01
  • I don't think I have the knowledge to help, but what are "robot" and "By.xpath()"? Sounds like they're demanding the XPath to be windows-1251 compatible, which is weird but might be configurable. – kumesana Jul 11 '18 at 08:03
  • I tried to rename and copy the word "WRITE" from other texts. This is not my cyrillic script. This is the "WRITE" button on google mail. – GRbI3yH Jul 11 '18 at 08:04
  • "robot" and "By.xpath()" in no way affect this error. In the class itself there is a comment of the developer and it has the symbol "И" there is also an error. Look at the image "error" – GRbI3yH Jul 11 '18 at 08:08
  • I see. From your screenshot I suppose you're using Maven. Maven will use the encoding set with Maven, not with Idea. Can you show your Maven configuration? – kumesana Jul 11 '18 at 08:12
  • @kumesana i added gradle file watch – GRbI3yH Jul 11 '18 at 08:22
  • Please don't post screenshots of things that can be posted as (code formatted) text. Edit your question, and replace those screenshots with the actual text. – Mark Rotteveel Jul 11 '18 at 08:28
  • I honestly don't see a fault to it but then again I trust very little in gradle. I'd try to add `compileJava.options.encoding = 'UTF-8'` – kumesana Jul 11 '18 at 08:28
  • @kumesana i add ` compileJava.options.encoding = 'UTF-8' ` did not help – GRbI3yH Jul 11 '18 at 08:37
  • The problem is clearly that the compiler is using windows-1251 for java files, when by what you're saying they are encoded in utf-8. Maybe windows-1251 is the default encoding on your platform and that's why gradle is using it? Unfortunately I have no idea how to tell gradle what encoding to use for java files. – kumesana Jul 11 '18 at 08:44
  • My platform Windows 10 and the default language is Russian – GRbI3yH Jul 11 '18 at 08:55
  • Something to check out: https://stackoverflow.com/questions/3017695/how-to-configure-encoding-in-maven – Victor Sergienko Jul 12 '18 at 19:50

3 Answers3

8

Setting encoding option for Java compilation should help:

compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
Nolequen
  • 3,032
  • 6
  • 36
  • 55
2

As an alternative way to solve this error:

"error: unmappable character (0x98) for encoding windows-1251"

you can also change the default encoding inside Custom VM Options...:

enter image description here

by adding, e.g.:

-Dfile.encoding=UTF-8

Help | Edit Custom VM Options, then restart IntelliJ IDEA.

invzbl3
  • 5,872
  • 9
  • 36
  • 76
0

I don't know if I am too late for this problem (pretty sure yes) but my advise could help to other guys - the problem is in cyrillic symbols. I had the same problem and I solved that by saving the file using format ANSI (if you use use some text editor like notepad, you can save your fie in ANSI encoding. Perhaps this option should be in IDE)