Java.lang.CharSequence cannot be resolved error while using sendKeys() using Selenium Webdriver

0 votes

I have imported the below packages but its throwing an error when using sendKeys();

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.testng.Assert;
import org.openqa.selenium.WebDriver;

The code is as below.

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.testng.Assert;
import org.openqa.selenium.WebDriver;

public class DemoCode {

    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");
      }
}

But I m receiving an error given below

The type java.lang.CharSequence cannot be resolved.

Can anyonehelp me in this.

Apr 4, 2018 in Selenium by ned_crew
• 1,620 points
752 views

1 answer to this question.

0 votes

You could try this,

myElement .sendKeys(new String[] { "text" });
or
myElement .sendKeys(new String { "text" });

answered Apr 4, 2018 by Johnathon
• 9,080 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Firefox Error: “Your connection is not secure” while launching driver with Selenium 3.0.1 using Java

Download Firefox 55 beta and set capabilities.setCapability("acceptInsecureCerts", true); Here ...READ MORE

answered Sep 17, 2018 in Selenium by Meci Matt
• 9,420 points
395 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
965 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,125 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
868 views
+2 votes
4 answers

sendKeys() not working in Selenium Webdriver

this work for me you should update your ...READ MORE

answered Aug 27 in Selenium by Afif
13,946 views
0 votes
2 answers

Radio button using Selenium WebDriver

You can try following code snippet: WebElement elem ...READ MORE

answered Aug 28 in Selenium by Abha
• 27,180 points
1,428 views