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 - closewndAfx Runs a script routine.
in close_AFX there is a while loop whitch closes several open windows. Normally it worked fine.
last week i tried to create a test script which should load pdf to pdfbox.
since this time in automated test, the test which would be opende is this reading routine.
klicking on runscript routine close afx and saying open in editor: opens the correct script
klicking on runscript routine close afx and "run from this operation" opens my pdfbox_laden script.
I know there is a nistake in reading routine (its written in java, and this would not work in javascript.
any idea why this could be?
actual version 11.11.1064.7
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.