I am Using IntelliJ Idea 2016.3.4 and JDK 1.8. It has an inspection that claims the following:

java: non-static method sendKeys(java.lang.CharSequence...) cannot be referenced from a static context

@Test(priority = 4)
public void requestSearchedISIN() {

I already tried below steps, but it didn't work

File-->Project Structure-->ProjectSettings-->Project In "Project Language level" field select "7-Diamonds, ARM, Multi-catch etc"

How should I resolve this?

1 Answer 1


WebElement is a class type. You need an instance of WebElement

Something like

//create the instance of the element you want to interact with
WebElement yourElement = driver.findElement(By.id(<your id goes here>));
//use that instance
yourElement.sendKeys("some text you want to send to your element");


sendKeys is a non-static method, meaning it can only be called when you have an instance of the class it's in, in this case WebElement. static methods on the other hand, don't need an instance to be called.

Consider the situation to understand why the Selenium devs chose to make sendKeys and other methods that interact with a webelement non-static. Would it make sense to click a WebElement when that object isn't actually attached to an actual element yet? Of course not. This is why you can only use those methods after you have located the element and created an instance.

It looks like you're trying to script some keyboard commands to the overall page instead of trying to interact with the elements directly. Selenium WebElements allow you to interact directly with an element, so you don't have to try to tab your way (Or press arrow keys) to the element you want to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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