Unable to JavascriptExecutor

Hello everyone,
I try to execute a simple modification of value thanks to JavascriptExecutor, but I do not understand why the script returns a NullPointerException

can you help me, please

...

String js = "document.querySelector('#history div:nth-child(4) > div > input').value = '0.47';)"
WebUI.executeJavaScript(js, null)
1 Like

thanks for your quick reply, but i get

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object ‘document.querySelector(’#history div:nth-child(4) > div > input’).value = ‘0.47’;’ with class ‘java.lang.String’ to class ‘org.openqa.selenium.JavascriptExecutor’

You need to remove your previous assignment to the js variable:

1 Like

thanks you Thomas :slight_smile: