I am building a small application for performing automatic checks on the Magento website using Selenium WebDriver in Java. I am working on learning Java, so I am adamant in understanding this with Java, rather than switching to Ruby or Python.
package com.huuginn.seleniumMagento;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class App
{
public static void main( String[] args )
{
WebDriver driver = new FirefoxDriver();
driver.get("http://plmkt.huuginn.com/");
WebElement searchField = driver.findElement(By.id("search"));
System.out.println(searchField.getClass().getName());
searchField.clear();
searchField.sendKeys("sample");
searchField.submit();
}
}
My getName () line confirms that I get the item I want from the page.
I get this error while compiling:
[INFO] Compilation error /seleniumMagento/src/main/java/com/huuginn/seleniumMagento/App.java:[25,13] sendKeys (java.lang.CharSequence ...) in org.openqa.selenium.WebElement cannot apply to (java.lang.String)
sendKeys expects a type parameter that implements CharSequence (java.lang.String qualifies as such), so I don’t understand why I get this error.
Java 1.6 Selenium 2.19, Maven.