Eval
(→Example) |
|||
Line 8: | Line 8: | ||
− | == Example == | + | == Example 1 == |
<pre> | <pre> | ||
Line 47: | Line 47: | ||
[[File:eval0.jpg]] | [[File:eval0.jpg]] | ||
+ | |||
+ | |||
+ | |||
+ | == Example 2: Running Javascript == | ||
+ | |||
+ | Eval can also be used to run javascript. | ||
+ | |||
+ | In this example, the function runs a piece of javascript that returns set cookies from a website and sets the cookies to a variable. | ||
+ | The cookies are also displayed in full in an alert window. | ||
+ | |||
+ | <pre> | ||
+ | ui text box("Wesbite URL:", #website) | ||
+ | navigate(#website, "Wait") | ||
+ | wait(2) | ||
+ | set(#blue, $eval("document.cookie"), "Global") | ||
+ | alert($eval("document.cookie")) | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | |||
+ | Type in a url to see what cookies the set command and the alert returns. |
Revision as of 17:24, 27 May 2014
This function returns the results of executing a piece of javascript or simple mathematical equations. $Eval is a Math Function.
With anything except for math equations, you will need a full website opened in the main browser in order to run the eval function.
Expression: the math or javascript expression being evaluated.
Example 1
navigate("http://www.ubotstudio.com/playground/simple-form", "Wait") type text(<about me textarea>, $eval($add(4, 4)), "Standard")
Typing 4+4 into the eval function brings up a new function called the add function.
$eval($add(4, 4))
navigate("http://www.ubotstudio.com/playground/simple-form", "Wait") type text(<about me textarea>, $eval($subtract(4, 4)), "Standard")
The subtract function appears when 4-5 is typed into the eval function.
$eval($subtract(4, 4))
Going back to our original script:
Running the script will fill the field with the correct answer for 4-4.
Example 2: Running Javascript
Eval can also be used to run javascript.
In this example, the function runs a piece of javascript that returns set cookies from a website and sets the cookies to a variable. The cookies are also displayed in full in an alert window.
ui text box("Wesbite URL:", #website) navigate(#website, "Wait") wait(2) set(#blue, $eval("document.cookie"), "Global") alert($eval("document.cookie"))
Type in a url to see what cookies the set command and the alert returns.