Reputation: 87
I have imported the following and still get an error when using sendKeys();
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.testng.Assert;
import org.openqa.selenium.WebDriver;
Note: I am using Selenium WebDriver with Eclipse.
The sample code is as below.
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.testng.Assert;
import org.openqa.selenium.WebDriver;
public class Practice {
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://www.facebook.com";
String tagName="";
driver.get(baseUrl);
tagName = driver.findElement(By.id("email")).getTagName();
System.out.println("TagName: "+tagName);
WebElement myElement = driver.findElement(By.id("username"));
myElement.sendKeys("text");
}
}
I received an error stating
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
Pointing at the line myElement.sendKeys("text");
Can one of you let me know what is incorrect here.
Upvotes: 4
Views: 45438
Reputation: 1
Issue will get resolved on upgrading to Eclipse Luna and then changing the compiler version to 1.8
Compiler version 1.8 is not available with the previous version
There you are getting The type java.lang.CharSequence error.
Upvotes: 0
Reputation: 1
Faced the same kind of issue.
Issue got resolved on upgrading to Eclipse Luna and then changing the compiler version to 1.8
Compiler version 1.8 is not available with the previous version
Upvotes: 0
Reputation: 29
Check Eclipse version Eclipse 4.3 (Kepler) and above version need to upgrade JAVA JDK 1.8.
After installation just check Eclipse: build path >> configure build path>> java compiler>> changed the compiler compliance level is 1.8
Note: 1. I suggest use Java JDK 1.8 version and Eclipse Eclipse 4.6 (Neon) 2. Selenium 3+ version jar file supported JAVA JDK 1.8 and above version only.
Upvotes: 0
Reputation: 537
I faced the same problem during using eclipse Kepler.
Problem domain:
My java compiler compliance level was 1.4
Solution:
so using build path >> configure build path>> java compiler>> changed the compiler compliance level to 1.7 or higher
This could solve the problem.
Upvotes: 1
Reputation: 37756
It needs to upgrade the Compiler Compliance. For Eclipse: Follow the steps below:
Upvotes: 2
Reputation: 389
As you are using JDK8, your compiler version should be 1.8 which you can get only with latest eclipse version - ECLIPSE LUNA. Alternate way is to downgrade your JDK8 to JDK7 and it will still work.
Upvotes: 0
Reputation: 41
This is because of your eclipse Editor.
Follow the steps below to overcome that error.
Here there are two things you need to check
A.Java Build Path > Libraries- Here editor should refer the version installed on your machine. If it's referring the old library files then remove it and click on Add Library and select the latest Jre system library from the List.
B.Java Compiler. Here Compiler compliance level should be the latest/ the one installed on your machine.
Upvotes: 0
Reputation: 2470
You could try this, similar issue has been answered here #sendKeys Issue
myElement .sendKeys(new String[] { "text" }); //You could create a string array
or simply
myElement .sendKeys(new String { "text" });
Upvotes: 2