'sendKeys' method shows error during compilation

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

'sendKeys' method shows error during compilation

guruprasad81
I get an error when i use sendKeys method.

my java code is below:

package com.selenium;

import org.openqa.selenium.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class WebDriverTest {

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.wikipedia.org");
driver.findElement(By.id("searchInput")).sendKeys("Selenium Software");
}

}

The error is

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)

Kindly help resolving this issue..
Reply | Threaded
Open this post in threaded view
|

Re: 'sendKeys' method shows error during compilation

softwaretestingforum
Administrator
Does not look wrong, Could you post snap shot of IDE where you encounter the error?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: 'sendKeys' method shows error during compilation

guruprasad81
Hi Tarun, i have attached the screenshot of my IDE.


On Thu, Dec 27, 2012 at 10:13 PM, tarunkumar [via Manual and Automated Testing] <[hidden email]> wrote:
Does not look wrong, Could you post snap shot of IDE where you encounter the error?

No Automated Testing




To unsubscribe from 'sendKeys' method shows error during compilation, click here.
NAML



--
Guruprasad R
Do it or Do not, there is no try!!

IDE.jpg (298K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 'sendKeys' method shows error during compilation

softwaretestingforum
Administrator
Package definition is wrong (first line)
It should be -

com.selenium;
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: 'sendKeys' method shows error during compilation

guruprasad81
IDE.jpg Sorry that i din't notice that typo. But here is the actual error which i have attached.
Reply | Threaded
Open this post in threaded view
|

Re: 'sendKeys' method shows error during compilation

guruprasad81
As a work around i found this: package com.selenium; import org.openqa.selenium.*; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class WebDriverTest { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); //driver.findElement(By.id("searchInput")).sendKeys("Selenium Software"); CharSequence[] arr = {"selenium software"}; driver.findElement(By.id("searchInput")).sendKeys(arr); } }
Reply | Threaded
Open this post in threaded view
|

Re: 'sendKeys' method shows error during compilation

nitincool4urchat
I'm using selenium 2.31 and I'm also having the same error in Netbeans.

Don't know what's going wrong. It used to work with earlier versions. I guess the method signature
takes CharSequence vargs, may be that has something to do.

Attached is the compilation error showing snapshot.

Reply | Threaded
Open this post in threaded view
|

Re: 'sendKeys' method shows error during compilation

softwaretestingforum
Administrator
String is also character array.
Could you place mouse on error and highlight it?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: 'sendKeys' method shows error during compilation

pratyush
hi ,

i know whats error coming here. actually error is :


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)

Solution :

Actually its not selenium error its error from perticular eclipse version.
we can set it from backend also .

OR

USE anonomous string array like :
driver.findElement(By.name("q")).sendKeys(new String[] {"Cheese!"});


Description : char sequence[] is always array so we can create object of "string[]" and use it ...
here i have taken anonomous array because we are using it only once.


Thanks and Regards,
Pratyush Mishra