For testing purposes I am trying to create a PDF that, upon opening, automatically closes itself and closes Acrobat Reader. Similar to having an Auto_Open macro in Word that executes: Application.Quit.
I have Acrobat Professional 9.0 but I cannot see how to do that. However, I see discussions of "Actions" (Acrobat Macros) on the Acrobat website.
Thanks.
Actions are not quite what you are looking for…
And Acrobat/Reader can not completely do what you are asking it for… For security reasons, it is not possible to programmatically terminate Acrobat/Reader. So, Quitting is not possible; all you can do is closing the document.
You would use Acrobat JavaScript for that. In order to see that it really works, I suggest to first try out a two-page document. To the second page, you add the following PageOpen script (later on, you can do that with the first page too):
this.dirty = false ;
this.closeDoc() ;
You create a PageOpen script by displaying the page tumbnails, and then select the context menu of the page you want to access. There you open the Page Properties… dialog, and switch to the Page Actions tab. Select Run a JavaScript as action for PageOpen, and add the code above.
Update, after comment by Neil Weicher :
If you want to delay the closing, you could use the setTimeOut() method, as showing in this example (which also uses the argument for closing the document without asking whether to save (the equivalent of setting the dirty flag to false); the delay is 5 seconds (5000 milliseconds)):
myDelay = app.setTimeOut("this.closeDoc(true) ; app.clearTimeOut(myDelay) ;" , 5000) ;
Note: although the timeout object should get reset when the document closes, it is safer to do it in the delayed script.
And that should do it.
Related
I am writing a test that verifies that a warning to the user before the user opens a document. If the user says that they still would like to open the document, the document opens in an external application (pdf or word).
But now I have an external application over the browser window, and it messes up for other tests.
So, what are the best practices around this kind of issue? Rewrite of the appliction to allow for not opening documents in test?
Added description:
The problem is twofold.
1) It starts processes (word and acrobat) that fills the desctop and requires resources from the test-slave
2) The external process seems to interfer with other tests since (guessing here) it is located over the browser window.
what i understood from your post is, the document(word/pdf) is opening in the browser window hence you are not able to proceed with further steps. If so, you can verify the Title to make sure the document is opened in browser window and can navigate back using below snippet.
driver.navigate().back();
Hope this helps.
What I understand from the line
'But now I have an external application over the browser window, and it messes up for other tests.'
is that once user clicks on open button a new window opens up (Window based application) since you have mentioned PDF or Word.
You can use robot class in such cases, below code snippet will close the current active window:
Robot rbt = new Robot();
rbt.keyPress(KeyEvent.VK_ALT);
rbt.keyPress(KeyEvent.VK_F4);
rbt.keyRelease(KeyEvent.VK_ALT);
rbt.keyRelease(KeyEvent.VK_F4);
Make sure you deal with sync issues properly so that intended window is closed instead of AUT.
Im using PDFtron on a windows store app project.
I have a page with a back button and a pdf viewer where i can edit the pdfs.
When im editing a pdf i have a tool bar with options like the ones in the samples, but i have a issue when i choose a Free Text tool and start writing on the pdf, if i press the back button while the Free Text tool is active ( the cursor is bliking) the text i wrote appears in the screen on the next page i navigate to.
How can i solve this?
The TextBox in question is part of the PDFViewCtrlTools that are used to create annotations. It is shipped with the sample application and is fully open source.
The TextBox is inside a popup, positioned to align itself on top of the PDFViewCtrl in the position where you tapped.
This TextBox needs to be closed before you go back. It is quite easy to do so by calling ToolManager.CreateDefaultTool(). In general, I would recommend taking a look at the samples and see what they're doing when the user tries to navigate away from the page.
Everytime you navigate away from a page with PDFViewCtrl, the ToolManager should call CreateDefaultTool so that whatever current tool is active (in this case the FreeTextCreate tool) can close itself and clean up.
Hello: I am using Selenium/Java to grab a PDF from a website. The website does not generate them in advance, but only after I clink on a link. When I do, the web server goes away for a few minutes, and then comes back with the content.
I'm using Firefox, and its built-in PDF viewer. When I click on the download link from the main browser window, it opens another window to receive the PDF content. In a few minutes the child window is filled with the PDF content, and all I need to do is click a download button on the Firefox toolbar, and then press a Save button on the confimration dialog. I have done both of these things, successfully, sometimes.
My problem, sometimes occurs when I execute the code to click on the child window's download button...
WebElement element = driver.findElement(By.id("download"));
element.click();
Sometimes, it just doesn't work. The statement:
driver.findElement(By.id("download"))
...never throws an exception, so it appears to always be successful. Yet, the subsequent element.click() will often not produce the expected results.
I've thrown about 100 darts at this problem, but I can't seem to find one that produces consistent results. I've tried introducing delays, calling findElement several times, trying to use the driver on the child window in ways to confirm its connection to that window (all with positive return values), but nothing seems to help make element.click() on the darn download link successfull.
I have found Selenium to be a rock-solid solution, especially when working through the primary window...it never misses a beat, and I'm really quite impressed about that behavior. This is my first Selenium project, and I hoping someone that has used it a bit more, might have a suggestion for this particular problem.
It's hard to answer this question without additional information about how the child window is populated. If the child window is using javascript to add the button to the page and define its behavior (which is likely), then the element could be actually present on the page when you look for it (i.e. no error will be thrown), but it might not be active yet or prepared to be clicked.
It might be a good idea to look at the element definition in the source for the child page to get a better idea of how the button is coded. If you have access to the web developers who designed/implemented the button even better. If you can wait to perform the click action until the button is in the desired state, this should solve the problem.
Additionally if the page is coded using a dynamic framework like Angular, you might be better off using Protractor for testing, which is based off of Selenium, but which is aware of updates in the view as they are occurring.
On windows 10.
I need to automate the repeated process of these steps.
1. Open up an image in GIMP. Scale it to 110%.
2. Export as somefile name(for example input001.jpg).
3. Go to http://deepdreamgenerator.com/ in a browser. click on button, browse to the exported file.
4. Wait for it to generate result, save image as result file (for example dream001.jpg).
then repeat from step 1 with the result file from step 4...but keep increasing the filename number so export it as input002.jpg...
What software would allow me to do this?
the only software i know of that * MIGHT * be able to automate that process is AutoHotKey
You would need to keep the windows which you're automating static (ie. make sure they don't move) and then write keyboard and mouse macros in autohotkey to press the buttons and do the things you want.
I tried AutoHotKey but didn't feel like learning a whole new scripting language so I found something simpler called GhostMouse.
It just has record,play,stop buttons.
after recording and closing out of program it asks if i want to save script. clicked yes gave it a name, and then edited the script file..and copied and pasted as many times as i wanted the script to run (before copying and pasting i deleted the last 3 lines which has to do with clicking the stop button which i didn't want the script to do).
You can also try Sikuli for same. It's an image comparator
http://www.sikuli.org/
Reference :-
http://doc.sikuli.org/tutorials/
Does anyone know how to call Adobe Reader from the command line to open a pre-populated Adobe Form (with Extensions enabled) e.g MRBIGSORDER0001.PDF, allow the user to alter it and then do a save and exit?
At present when the populated form is opened for updating, hitting Save or the Save button on the toolbar prompts the user with "Save As", which is causing them to create multiple versions.
This issues appears to be related to new Security / Sandbox settings from Adobe Reader X onwards.
--
It is not clear exactly how to stop this from happening on a fine "level" but going to:
Edit --> Preferences --> Security (Enhanced)
Turning off "[ ] Enable Protected Mode at Startup" certianly stops this odd behavior cold.
I am looking into "Priveledged Locations" settings to see if I can fine tune this.
cheers,
JonHD
Make sure you are not using the Preview pane in the windows View. If you just use the Navigation pane and not preview or details pane then you should be able to just save.
It's like windows is holding the file open and so it is an active file and you can't just do a save you have to do a save as.
I think it must be a bug with the windows update
If you want end-users to be able to save a document that has been filled out, you need to Reader-enable the form.
Reader-enabling can only be done with Adobe software as the concept consists of digitally signing the document using a private key owned by Adobe. This digital signature unlocks functionality in Adobe Reader that is otherwise only available in Adobe Acrobat.
So, the solution is:
Make sure that the original form is reader-enabled (use Adobe Acrobat to do this),
Do not break the reader-enabling when pre-filling the form,
Thanks to the two previous steps, the "Save" button will work in your current set-up.