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
468 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You could try this,

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

answered Apr 4, 2018 by Johnathon
• 9,070 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,400 points
193 views
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
1,416 views
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,050 points
142 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
531 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
134 views
+1 vote
3 answers

sendKeys() not working in Selenium Webdriver

driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys("UserName",Keys.TAB); By using a comma you can ...READ MORE

answered Feb 7 in Selenium by Priyaj
• 56,140 points
9,084 views
0 votes
1 answer

Radio button using Selenium WebDriver

This code will help you out: import java.util.List; ...READ MORE

answered Apr 11, 2018 in Selenium by Johnathon
• 9,070 points
793 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.