Reputation: 13
I need to execute the following evaluate function which should take an argumentlist
|@{argList}= | arg1 | arg2 | arg3 |
| Execute JavaScript | var header=document.evaluate('//span[contains(text(),"Manage VLAN Profiles")]/following::table[contains(@class,"x-grid")]/tbody/descendant::tr/descendant::td/descendant::*[contains(text(),"AccessVLAN")]',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;
return header.textContent; |
Here I need to pass the @{argList}
to the JavaScript function.
Upvotes: 1
Views: 8252
Reputation: 2384
If your variables are simple types you can just embed them in the script and Robot Framework will expand them before actually invoking Execute JavaScript.
${argList}= Create List Sally 45
Execute JavaScript alert('Hello ${argList[0]}, you are ${argList[1]} years old');
If the above does not work for you and you want to be able to pass arguments directly, you can by accessing the WebDriver instance. You can reference the arguments passed via the array called arguments.
${argList}= Create List Sally 45
${s2l}= Get Library Instance Selenium2Library
Call Method ${s2l._current_browser()} execute_script alert('Hello ' + arguments[0] + ', you are ' + arguments[1] + ' years old'); @{argList}
If you want this functionality you should request it on the issue tracker. Note the on failure mechanism will not work when doing this.
Upvotes: 1