Forum Discussion

petra's avatar
petra
Contributor
8 years ago
Solved

running script routine takes wrong script

Hi Community!   I have a few nini scripts to automate my keywordtests.   a snippet of my current test:    BitBtnPrint ClickButton Clicks the 'BitBtnPrint' button. Run Script Routine close_Afx ...
  • HKosova's avatar
    8 years ago

    Hi Petra,

     

    The problem is that the line

    docObj = loadDocument("C:\TestPDF\Document.pdf")

    is in the global scope of the script, outside of any functions. The code in the global scope is always executed before any other script functions. So when you try to run the closewndAfx() function, this line is triggered first and calls the loadDocument() function.

     

    To avoid the problem, comment out this line or move it inside some wrapper function such as test_loadDocument().

     

    On an unrelated note, in JScript/JavaScript you need to double the backslashes in paths: C:\\TestPDF\\test2.pdf. Also, you are passing a file name to loadDocument but the function does not actually have a parameter -- so that code might not work as intended.