unable to use sendKeys"sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)"
Solution 1
Follow the steps below if you are using eclipse:
- Right click on your java project and select Build Path -> Click on Configure Build Path...
- In project properties window: Click/select Java Compiler at the left panel
- At the right panel: change the Compiler compliance level from 1.4 to 1.7 or higher
- Lastly Click on Apply and OK
Solution 2
Set the JRE System Library again. If you use eclipse follow the steps below:
- Go to project properties
- Select Java Build Path at the left panel -> Select Libraries tab at the right
- Click/select JRE System Library[] -> Click Edit button at the right side
- Set your preferred JRE and click Finish button
- Lastly click OK button from the project properties pop up window
Instead of editing you can also do by deleting and adding. The steps are:
- Right-click on project » Properties » Java Build Path
- Select Libraries tab
- Find the JRE System Library and remove it
- Click Add Library... button at right side » Add the JRE System Library (Workspace default JRE)
Comments
-
Puneet Purohit almost 2 years
I am trying to send "String" as argument in sendKeys method [type WebElement] but system is using it as char sequence, so I am not getting proper output.
public static void setGridDropDownValue(Selenium selenium, WebDriver webDriver, String strGridId, int nRowIndex, int nCellIndex, String strValue) { String strXPath = "//div[@id='"+strGridId+"']//table/tbody/tr[2]/td/div/div/table/tbody/tr["+(nRowIndex+2)+"]/td["+(nCellIndex+1)+"]/"; selenium.click(strXPath); selenium.doubleClick(strXPath); strXPath = "//select"; Select selStatus = new Select(webDriver.findElement(By.xpath(strXPath))); List<WebElement> we = selStatus.getOptions(); for(int i = 0; i< we.size();i++) { WebElement wei = we.get(i); System.out.println("Options : "+wei.getText().toString()); if(wei.getText().toString().equals(strValue)) { wei.sendKeys(strValue); break; } } }
For example : My dropdown have 4 options(Partial,Done,Verified,Delete). If selected value is "Partial" and I am sending key "Done" then it is working fine, but if selected value is "Verified" and I am sending "Done" then system is selecting "Delete". I am not getting its working procedure but I think system is comparing characters. If selected value is "Verified" and I am sending "Partial" then system is selecting "Partial"(working proper).
F.Y.I. : My dropdown is invisible until user double click on that element.
Please let me know if there is any way to send "String" with sendKeys method. TIA
-
Puneet Purohit about 10 yearsMy options are not visible so findElement(strxpath) wont work here.
-
hk6279 over 7 yearsWhat is the difference between your answer and Ripon Al Wasim's one?