I am using Selenium writing in Java by VS Code.
I am unable to compile this line of code since there is a red line under the method sendKeys
.
The line of code is:
driver.findElement(By.xpath("xpath")).sendKeys("Cologne");
Error is shown as:
The method sendKeys(String) is undefined for the type ByJava(67108964)
This error message…
The method sendKeys(String) is undefined for the type ByJava(67108964)
…implies that there is a configuration issue within the environmental settings.
As per this discussion Solution for sendkeys(CharSequence) in Selenium while you start writing code using Selenium‘s java client, at times your project Java Compiler version will be below v1.5 and sendKeys()
will won’t be read by the compiler. In these cases you need to upgrade the compiler version to 1.5 and above.
Solution
You need to make the following changes:
- Change the compiler version from old version to 1.5 or greater.
- Additionally, you may need to go to
Java Build Path
->Libraries
->Select Java SE 1.8
(if Java 8 is installed)