Forum Discussion

Arnelys's avatar
Arnelys
Occasional Contributor
10 months ago
Solved

How can I open a notepad downloaded from the browser?

I'm running a test with scripts, using VBScripts. The test consists of downloading a browser notepad, opening it, checking content and closing it. The notepad is downloaded but I can't open it automa...
  • rraghvani's avatar
    10 months ago

    That makes it slightly tricky. Is there any way of figuring out the format of the filename, to open? Otherwise the other solution is to add your browser WndClass property value to MSAA in Project Settings. Here, I've added Chrome WndClass property value,

    This will expose the browser UI controls in TC.

     

    Ensure you have an application associated with the file type.

  • Arnelys's avatar
    10 months ago

    I found the final solution. It will work for when the file has a dynamic name or not, I leave you step by step

     

    1. Do what is indicated in this link to interact with the download bar of the browser as an object, recognized by Object Spy

    2. Use the Click action on the object, if the file has a dynamic name (which is never the same) follow steps 3 and 4

     

    3. Object spy provides the mapped name of the object, complete up to the filename, you must remove the last child which is the file itself and only handle the browser download bar as the object

    I show you with image and example:

    The full mapped name of the object (downloaded file) is as follows:

    Aliases.browser.Form("Acquisition Shipment Detail - Google Chrome").Pane("Acquisition Shipment Detail - Google Chrome").Pane(0).Pane(0).Pane(1).Grouping("Downloads bar").Grouping("FileName.")

    You must eliminate the part marked in italics, in this way the object that you will handle will be the download bar of the browser

     

    4. When performing the Click action you must include the ClientX, ClientY parameters, these coordinates are of the object itself and not of the screen. More information about Click(ClientX, ClientY) here

    In my case, the code was as I show you below, maybe it is not the most optimal but I am learning:

    (i'm using VBScript)

    dim blnTest
    set blnTest = Aliases.browser.Form("Acquisition Shipment Detail - Google Chrome").Pane("Acquisition Shipment Detail - Google Chrome").Pane(0).Pane(0).Pane(1).Grouping("Downloads bar")
    call blnTest.Click(10,20)

     

    Note: The coordinates 10,20 of the browser bar is the upper left corner of the bar

     

    A pleasure to share my experience on this topic that gave me so many headaches

    🙂