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

5
  • Did you google the error you received? What did you find? What did you try to resolve the issue? Commented Jun 17, 2016 at 19:01
  • try with initializing the variables in main class itself Commented Jun 18, 2016 at 7:03
  • your script is working fine. I have just tried. Commented Jun 18, 2016 at 7:08
  • does it has to do with my setup. I have the selenim jar, jdk libraries. Anything else I require. Commented Jun 22, 2016 at 15:46
  • The code is running fine now. I forgot to add Selenium Standalone Server jar file. Commented Jun 22, 2016 at 15:58

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

1 Comment

There seem to error starting this line WebDriver driver = new RemoteWebDriver(new URL(URL), caps);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.