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

16,832

Solution 1

Follow the steps below if you are using eclipse:

  1. Right click on your java project and select Build Path -> Click on Configure Build Path...
  2. In project properties window: Click/select Java Compiler at the left panel
  3. At the right panel: change the Compiler compliance level from 1.4 to 1.7 or higher
  4. Lastly Click on Apply and OK

enter image description here

Solution 2

Set the JRE System Library again. If you use eclipse follow the steps below:

  1. Go to project properties
  2. Select Java Build Path at the left panel -> Select Libraries tab at the right
  3. Click/select JRE System Library[] -> Click Edit button at the right side
  4. Set your preferred JRE and click Finish button
  5. 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:

  1. Right-click on project » Properties » Java Build Path
  2. Select Libraries tab
  3. Find the JRE System Library and remove it
  4. Click Add Library... button at right side » Add the JRE System Library (Workspace default JRE)
Share:
16,832
Puneet Purohit
Author by

Puneet Purohit

@Reliance

Updated on June 05, 2022

Comments

  • Puneet Purohit
    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
    Puneet Purohit about 10 years
    My options are not visible so findElement(strxpath) wont work here.
  • hk6279
    hk6279 over 7 years
    What is the difference between your answer and Ripon Al Wasim's one?