Unable to pass string using sendKeys method? | Selenium Forum
M
Posted on 04/02/2016
Hi All,

I am unable to pass string using sendKeys() method?

I get this error below.
Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String).

Java version on my system is 1.8. Not sure if the problem is due to the Java version?Please help

Thanks,
Asha

M
Replied on 04/02/2016

Does the webelement in the question accepts string characters ? Try manually entering some string "XYZ" in it .

if you have to enter some integer in that webelement and if you are importing it from xlsx, then convert it to int even b4 using sendkeys . Note : when importing from xlsx every data type would be converted to string.


M
Replied on 04/02/2016

seem like you're missing jar files.


M
Replied on 08/02/2016

I get the same error "Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)" when I enter "XYZ"

jar files missing ? could you please let me know.


M
Replied on 08/02/2016

selenium jar files download them and add them.


M
Replied on 10/02/2016

I added the selenium jar files. I don't see any changes still.

-------------------------------------------------------
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class testing_gmail {


public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
driver.get("http://gmail.com");

WebElement emailId=driver.findElement(By.id("Email"));
emailId.sendKeys("xyz")
// WebElement Button=driver.findElement(By.id("next"));
//Button.click();

int x= emailId.getLocation().x;
int y=emailId.getLocation().y;
System.out.println(x + "----" +y);

//driver.findElement(By.id("Email")).sendKeys("asha");
}

}



error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)

at testing_gmail.main(testing_gmail.java:15)


M
Replied on 10/02/2016

emailId.sendKeys("xyz");

semicolon is missing in your code, add ; to the line and try again


M
Replied on 12/02/2016

Even after adding semi colon it does'nt work. I get the same error.


M
Replied on 12/02/2016

i tried your code its working for me. there must be some missing jar files. delete all your jar files and download them again.