How to enter the input text using JavascriptExecutor?

How to pass XPath in JavascriptExecutor?

I am developing a web application that has a form with some input fields. I have a JavaScript function that gets invoked on keydown of input fields and submits the form. I need to pass the XPath of the input field to the JavaScript function so that I can pass the value of the input field to the JavaScript function and add it to the form.

How can I pass XPath to the JavaScript function? XPath is not a language but an XML Query Language, it's quite limited and doesn't support XPath 2.0.

You'll need to find a different way to pass values from the client to the server if you want to use XPath.

Related Answers

How to return value from JavaScript executor in Selenium?

I am working on a web application. Here I h...

How to send enter key in Selenium?

You can use the sendKeys function. First, you'...

How to send values in Selenium without using sendKeys?

From CMD.exe /? The keystring can contain...