Skip to main content

JS Actions

Perform User Interactions such as Type, Wait, Click, Evaluate JS Script, Scroll, Scroll_till_end and more using "actions" parameter in GetOData Request.

The JS actions should be in proper format and encoded and so we recommend using our API Dashboard to create the accurate code for the request.

For Example: To Perform a Type action in your request:

import requests

params = {
'apiKey': '5297e11d91b6647eb47f76c5',
'url': 'https://myexternalip.com/raw',
'location': 'Auto',
'js_enabled': 'Yes',
'antibot_level': '1',
'actions':"""[
{"action": "type", "xpath":"xpath_of_element_to_type" }
]"""
}

url = 'https://api.getodata.com/'

response = requests.get(url, params=params)
responseData = response.json()
print(responseData)

Note: Make sure the key and value pair are surrounded by double quotes and not single quotes to prevent format error. Xpath values can have single quotes. Also last action should not have a "," after ending. This causes internal server error.

Here are the example of all the actions you can perform in any request:

actions = [
{"action": "type", "value": "Text To Add", "xpath":"//xpath_of_element_to_type"},
{"action": "wait", "value": 5},
{"action": "click", "xpath":"//xpath_of_element_to_click"},
{"evaluate": "evaluate", "value": "js_script_to_run_on_page"},
{"action": "scroll_till_end"},
{"action": "scroll", "top": 400}
]

For any Questions, feel free to contact customer support through bottom right chat option on Homepage.