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,610 points
4,698 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,090 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,460 points
1,763 views
0 votes
1 answer
0 votes
2 answers

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,500 points
13,485 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,029 views
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,910 points
7,143 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,815 views
+2 votes
4 answers

sendKeys() not working in Selenium Webdriver

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

answered Aug 27, 2019 in Selenium by Afif
30,041 views
0 votes
2 answers

Radio button using Selenium WebDriver

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

answered Aug 28, 2019 in Selenium by Abha
• 28,140 points
4,663 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP