Random rnd = new Random();
char supName = (char) (rnd.nextInt(26) + 'a');

I have a supplier text area, if I put any character then it will show supplier suggestion based on input like google suggestion (eg. if I enter "a" then it will show suggestion of all supplier whose name start with A.)

I wrote above code for the same but it is not working with sendKeys.

I am beginner to selenium.

  • That's because you're declaring supName as a char variable, but the sendKeys function applies to a WebElement type, and you're using supName for both variables. Declare your WebElement then use that variable to .sendKeys(supName) May 29 '18 at 13:16
  • Sorry, i do typo error while posting. i edited my question. My webelement is supID here. thanks @BillHileman May 29 '18 at 13:33
  • What is the tag type of supID? Is it input? Is this, by chance, Appium (mobile app)? Can you please show both the HTML code for the text input and the locator you are using to retrieve it in your original post? May 29 '18 at 13:35

Convert char to string and then pass it to the sendKeys function:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.