SamZi SamZi - 1 year ago 86
Javascript Question

I want to make a Javascript browser scripts in console. What syntax is there to click/enter text/find values?

Im a beginner in JavaScript and I want to make scripts in the console of the browser to do tasks. I cant find the syntax to do this. The only command I know of is document.getElementById() however Im struggling to find commands to click or enter text into a search box or something to input text in.
Does anyone know how to do this?

Example of what I want to achieve:

Type Hello into the google search bar and press enter.

Answer Source

You could use ruby with Capybara and Cucumber to do that and if you still want to use javascript you can inspect the input and get the id and then do this:

document.getElementById('lst-ib').value = "Hello";

and for the click you could try this:


but it didn't work for me.

And if you want to learn javascript you can do it in codeschool or codecademy for example.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download