I have a file js in my project
export function myFunction(parametro) {
return "This is result " + param;
}
and my file .robot
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Carregar Funções JavaScript
Open Browser https://google.com Firefox
Execute JavaScript var script = document.createElement('script');
... script.src = '/external-libs/robot-shared-function/index.js';
... document.head.appendChild(script);
Usar Função JavaScript
${resultado}= Execute JavaScript return minhaFuncaoGlobal('algumParâmetro');
Log ${resultado}
But in results I have :
Usar Função JavaScript | FAIL |
JavascriptException: Message: ReferenceError: myFunction is not defined
------------------------------------------------------------------------------
Teste-Lib | FAIL |
2 tests, 1 passed, 1 failed
I would like know how to use external function of file js