-2

I am trying to run this selenium test code from Browserstack but I cannot get pass the error I am getting.

Code:

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.URL;

public class JavaSample {

  public static final String USERNAME = "username";
  public static final String AUTOMATE_KEY = "key";
  public static final String URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub";

  public static void main(String[] args) throws Exception {

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("browser", "IE");
    caps.setCapability("browser_version", "7.0");
    caps.setCapability("os", "Windows");
    caps.setCapability("os_version", "XP");
    caps.setCapability("browserstack.debug", "true");

    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
    driver.get("http://www.google.com");
    WebElement element = driver.findElement(By.name("q"));

    element.sendKeys("BrowserStack");
    element.submit();

    System.out.println(driver.getTitle());
    driver.quit();

  }
}

The error I am getting is

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
    The method sendKeys(CharSequence...) from the type WebElement refers to the missing type CharSequence

    at mypackage.JavaSample.main(JavaSample.java:30)

I have the selenium library and java library on the project. I am using eclipse.

1 Answers1

0

A similar issue was reported here- Error when using sendKeys() with Selenium WebDriver Java.lang.CharSequence cannot be resolved. Can you check if it is something similar?

Community
  • 1
  • 1
Nishant
  • 66
  • 4