Topic
  • 3 replies
  • Latest Post - ‏2013-01-07T14:44:13Z by SystemAdmin
Eric_Lewandowski
Eric_Lewandowski
1 Post

Pinned topic RFT loses browser when saving a file

‏2012-10-11T17:46:15Z |
I am currently dealing with a set of scripts that end up saving a Word document before trying to close the browser. However, once the save dialog is complete, RFT seems to lose the browser, and throws an ObjectNotFound error. Whenever the script fails at this location, I can use the "Repair" options to fix it, but when I open the object map and compare the current state of the browser to the saved recognition properties, RFT shows them as all matching.

Below is a snippet of the code at the end of the script.

// This is the File Download dialog.
dialog_htmlDialogButtonSave().click();

// Window: iexplore.exe: Save As
saveAswindow().inputKeys("save Path goes here.");
// These lines tab over to the Save button, and hit Enter. This closes the save dialog.
saveAswindow().inputKeys("{TAB}{TAB}");
saveAswindow().inputKeys("{ENTER}");

//This line is supposed to close the browser. This is the line currently failing.
browser_htmlBrowser(document_nextPageNXT4(),DEFAULT_FLAGS).close();
Is there any way in the code to get RFT to recognize the browser again? I have to do this across 50+ scripts, and need the scripts to close out automatically so that the next doesn't error out.
Updated on 2013-01-07T14:44:13Z at 2013-01-07T14:44:13Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: RFT loses browser when saving a file

    ‏2012-10-11T21:45:22Z  
    Could you add the recognition properties and full error/exception text?
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: RFT loses browser when saving a file

    ‏2012-10-11T21:51:21Z  
    >> //This line is supposed to close the browser. This is the line currently failing.
    >> browser_htmlBrowser(document_nextPageNXT4(),DEFAULT_FLAGS).close();"

    Without that info my first guess is unless you need multiple pages open at once and are specifically trying to close the browser you just finished with, I think maybe your document document_nextPageNXT4() may be the issue if you have closed the word doc then the recognition properties it is using may not match (simplest way to confirm is to breakpoint that line and try to 'highlight' the document_nextPageNXT4 TestObject (if it can't find it then the line you are using won't work).

    Try a simple browser_htmlBrowser().close() instead.
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: RFT loses browser when saving a file

    ‏2013-01-07T14:44:13Z  
    >> //This line is supposed to close the browser. This is the line currently failing.
    >> browser_htmlBrowser(document_nextPageNXT4(),DEFAULT_FLAGS).close();"

    Without that info my first guess is unless you need multiple pages open at once and are specifically trying to close the browser you just finished with, I think maybe your document document_nextPageNXT4() may be the issue if you have closed the word doc then the recognition properties it is using may not match (simplest way to confirm is to breakpoint that line and try to 'highlight' the document_nextPageNXT4 TestObject (if it can't find it then the line you are using won't work).

    Try a simple browser_htmlBrowser().close() instead.
    Hi,

    you can try this:

    public static void closeIE() {

    RootTestObject r = getRootTestObject();
    TestObject[] browsers = r.find(atChild(".processName", "iexplore.exe"));

    for (int i = 0; i < browsers.length; i++) {

    try {
    ((BrowserTestObject) browsers[i]).close();

    } catch (Exception e) {

    }

    }
    unregisterAll();

    }
    or this:
    Runtime.getRuntime().exec("taskkill /f /IM iexplore.exe");

    you can use this to determine if IE is running:

    public static boolean checkIfProcessIsRunning(String strProcesName) {

    String strDOScmd = new String(
    "c:\\Windows\\System32\\tasklist.exe");

    boolean blReturn = false;

    try {
    String line;

    Process p = Runtime.getRuntime().exec(strDOScmd);
    BufferedReader input = new BufferedReader(new InputStreamReader(
    p.getInputStream()));
    while ((line = input.readLine()) != null) {
    // System.out.println(line); // <-- Parse data here.
    if (line.contains(strProcesName)){
    blReturn = true;
    }
    }
    input.close();
    } catch (Exception err) {
    err.printStackTrace();
    }
    return blReturn;
    }
    regards,
    g