Question / Problem:
The first symptom that a robot might have encountered an error while running Java Script is incomplete page loading (the page doesn't load at all or just some elements are missing).
Java Script errors can be seen when using Browser Tracer to monitor the robot execution (in the Java Script tab). E.g.
"Uncaught SyntaxError: Use of const in strict mode"
"WebSocket is not defined"
Answer / Solution:
The Java Script engine in webkit robots supports ECMA 5 standards. Therefore, the new features in ECMA 6 (or later) are not supported.
Some of these features include:
- Arrow function (=>)
- Template literals (backquote ` )
- const in strict mode
- WebSockets - WebSocket is not supported in webkit and it's actually not compatible with webkit (because WebSocket keeps the connection open while webkit works in a completely opposite way; webkit gets all the data from a webserver then closes the connection and displays the data).
In some cases, it's possible to make code changes such that the robot can still execute the code.
|Error /Issue||Possible workaround|
|"Unexpected identifier" in Browser Tracer and code contains "let"||
replace "let " with "var "
Note: it's recommended to rather replace pattern "\s(let)\s" to avoid replacing words like "letter" or "delete" as well.
In a lot of cases, editing the code would be very complicated (or impossible e.g. WebSocket component). In these cases, it's recommended to use the Chromium Embedded Framework (CEF) browser rather than webkit.