Error using sendKeys () with Selenium WebDriver Java.lang.CharSequence could not be resolved

I 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.

Sample code is as follows.

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 got an error message

The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files

Line reference myElement.sendKeys("text");

Some of you will tell me what's wrong here.

+4
source share
7 answers

You can try this, a similar problem was answered here #sendKeys Issue

myElement .sendKeys(new String[] { "text" }); //You could create a string array 

or simply

myElement .sendKeys(new String { "text" });
+1
source

He needs to update the compiler match. For Eclipse, follow these steps:

  • java " " → " ".
  • : / Java
  • : 1.4 1.7
  • "" ""

enter image description here

+2

eclipse Kepler.

:
java 1.4

:
, → configure build path → java compiler → 1.7

.

+1

- eclipse.

.

  • java.
  • " " > " ".

,

A.Java > . , . , " " Jre .

B.Java. / .

0

JDK8, 1,8, - ECLIPSE LUNA. - JDK8 JDK7, .

0

Eclipse Eclipse 4.3 (Kepler) JAVA JDK 1.8.

Eclipse: → → java → 1.8

: 1. Java JDK 1.8 Eclipse Eclipse 4.6 (Neon) 2. Jar Selenium 3+ JAVA JDK 1.8 .

0

.

The problem was resolved when upgrading to Eclipse Luna , and then changed the compiler version to 1.8

Compiler version 1.8 is not available with previous version

0
source

Source: https://habr.com/ru/post/1548043/


All Articles