dale_waterworth
12 years agoOccasional Contributor
Handling the adobe popup for string found or not
Hi
Please see image...
I'm searching through the contents of a pdf using Adobe Reader using the ctrl + f.
My check is if the string does not exist, then check for the dialog to appear and and click ok. if it is found then the box does not appear, which is fine and this denotes a find.
My main pdf window uses (jscript):
Sys.Process("AcroRd32", 2).Window("AcrobatSDIWindow", "*", 1)
the confirm box is:
Sys.Process("AcroRd32", 2).Window("#32770", "Adobe Reader", 1).Window("GroupBox", "", 1)
How can do the error check without it breaking? I've tried various conditions in the if statement such as waitProcess etc but cant find the correct one to use.
Code - this works fine when the text isn't found but when the dialog doesn't appear it breaks and i get an error:
Cannot obtain the window with the window class '#32770', window caption 'Adobe Reader' and index 1. See Additional Information for details. 16:31:22 Normal :
To run you should be able to open a pdf in adobe and run this keyword function against it. change the 'find' variable to contain words in the pdf doc and then the problem will occur
function findtText() {
var find = "imNotHere, the, a"
var findList = find.split(",");
var i =0;
var notFound = false;
var notFoundStr = "";
var adobe = Sys.Process("AcroRd32", 2).Window("AcrobatSDIWindow", "*", 1);
var val;
for(i = 0; i < findList.length; i++) {
val = aqString.Trim(findList);
adobe.Keys("^f[BS]");
adobe.Keys("^f" + val + "[Enter]");
aqUtils.Delay(750);
if(Sys.Process("AcroRd32", 2).Window("#32770", "Adobe Reader", 1).Window("GroupBox", "", 1).Exists) {
Sys.Process("AcroRd32", 2).Window("#32770", "Adobe Reader", 1).Window("GroupBox", "", 1).Window("Button", "OK", 2).Click();
notFoundStr += "[" +val + "]";
notFound = true;
} else {
Log.Checkpoint("Found: [" + val + "]");
}
}
if(notFound) {
Log.Error("Could not find [" + notFoundStr + "] in pdf");
}
}
Cheers
Please see image...
I'm searching through the contents of a pdf using Adobe Reader using the ctrl + f.
My check is if the string does not exist, then check for the dialog to appear and and click ok. if it is found then the box does not appear, which is fine and this denotes a find.
My main pdf window uses (jscript):
Sys.Process("AcroRd32", 2).Window("AcrobatSDIWindow", "*", 1)
the confirm box is:
Sys.Process("AcroRd32", 2).Window("#32770", "Adobe Reader", 1).Window("GroupBox", "", 1)
How can do the error check without it breaking? I've tried various conditions in the if statement such as waitProcess etc but cant find the correct one to use.
Code - this works fine when the text isn't found but when the dialog doesn't appear it breaks and i get an error:
Cannot obtain the window with the window class '#32770', window caption 'Adobe Reader' and index 1. See Additional Information for details. 16:31:22 Normal :
To run you should be able to open a pdf in adobe and run this keyword function against it. change the 'find' variable to contain words in the pdf doc and then the problem will occur
function findtText() {
var find = "imNotHere, the, a"
var findList = find.split(",");
var i =0;
var notFound = false;
var notFoundStr = "";
var adobe = Sys.Process("AcroRd32", 2).Window("AcrobatSDIWindow", "*", 1);
var val;
for(i = 0; i < findList.length; i++) {
val = aqString.Trim(findList);
adobe.Keys("^f[BS]");
adobe.Keys("^f" + val + "[Enter]");
aqUtils.Delay(750);
if(Sys.Process("AcroRd32", 2).Window("#32770", "Adobe Reader", 1).Window("GroupBox", "", 1).Exists) {
Sys.Process("AcroRd32", 2).Window("#32770", "Adobe Reader", 1).Window("GroupBox", "", 1).Window("Button", "OK", 2).Click();
notFoundStr += "[" +val + "]";
notFound = true;
} else {
Log.Checkpoint("Found: [" + val + "]");
}
}
if(notFound) {
Log.Error("Could not find [" + notFoundStr + "] in pdf");
}
}
Cheers