unable to use sendKeys"sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)"

8,160 views
Skip to first unread message

visha...@gmail.com

unread,
Dec 3, 2013, 5:59:09 AM12/3/13
to webd...@googlegroups.com
I get following error when i use send keys:
sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)"


Code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebElement;

public class TestMethod1 {


/**
* @param args
*/
public static void main(String[] args) {
WebDriver driver= new FirefoxDriver();
driver.get("http://www.google.com");
WebElement element= driver.findElement(By.name("q")).sendKeys("cheese");


element.submit();

}

}



Selenium webdriver:2.37
JRE:1.7

Can you please help me?

susanth.nair

unread,
Dec 3, 2013, 1:46:25 PM12/3/13
to webd...@googlegroups.com
create an action and do the same

new Actions(driver).sendKeys(array).perrfom();



--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/groups/opt_out.

Manoj

unread,
Dec 4, 2013, 2:48:43 PM12/4/13
to webd...@googlegroups.com
Try below steps--

1.Paste this List<String> abc=new ArrayList<String>(); on your class
2. Mouse over on "List" and import java.util package
3. Now system prompt you to change the JRE
4. Press Ok to change the JRE


--Manoj Hans

darrell

unread,
Dec 4, 2013, 3:09:29 PM12/4/13
to webd...@googlegroups.com
The code looks correct. I would suspect that something in your project settings are not set correctly. The sendKeys method does take a CharSequence array but your JVM should be able to easily promote your String to an array of CharSequence. Your project settings might have a strict setting to prevent automatic promotion of data types.

tony Kent

unread,
Mar 30, 2015, 2:37:53 PM3/30/15
to webd...@googlegroups.com
I encountered the same issue when type the code in eclipse,in my situation,it's the setting of Compiler is improper and the code  failed to be compiled.
As darrell said, to check the compiler of the project and make it 1.5 or later. In eclipse,do as following:
In menu bar, Window > Preferences
In Preferences dialog, expand Java and click on 'Compiler' check 'Compiler compliance level' under JDK Compliance.(this is my workaround)
you may also want to check installed JREs,in the same  'Preferences' dialog
expand 'Java' and click 'Installed JREs'.
Hope this helpful & guluk.

2013年12月3日火曜日 18時59分09秒 UTC+8 visha...@gmail.com:

Subhash Gaddampally

unread,
Mar 31, 2015, 1:35:49 PM3/31/15
to webd...@googlegroups.com
edit like this

WebElement element= driver.findElement(By.name("q")) ;
element.sendKeys("cheese");


because sendKeys is void method.

Aniket Gadre

unread,
Apr 1, 2015, 2:08:41 AM4/1/15
to webd...@googlegroups.com
I have seen this issue happening if you are using JDK 8 with older version of eclipse. Also as Tony suggested, check the compiler settings

Best Regards,
Aniket Gadre
 
Programming can be fun, so can cryptography; however they should not be combined.

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

mohit....@quovantis.com

unread,
Aug 2, 2016, 7:51:08 AM8/2/16
to webdriver
Not working this
Reply all
Reply to author
Forward
0 new messages