Forum Discussion

twhitehouse's avatar
twhitehouse
Contributor
10 years ago

Sign into gmail after dynamic reload of everything previously mapped in Name Mapping

My script will successfully sign into Gmail, click on an email, and click on the link in that email if and only if I do not sign out of Gmail or close the browser.  As soon as the user is no longer signed into Gmail, even though my automation script can successfully sign the same user into Gmail, the mapping is no longer correct for what Gmail has at that point.  Gmail ( and even mail.com for that fact ) changes the links dynamically upon page load.  I can not stay signed into Gmail the whole time. 

 

Also, when I signed out of Gmail and signed back in, Test Complete wanted me to check out the Name Mapping again to create new links when I tried another property check point.  Test Complete made a new mapping that was not the same as the one that worked before I signed out of Gmail.  So, I am very certain that Gmail is changing things on me when I sign back in as the same user.

 

So, in my automation script, how can I still sign out of Gmail, sign back into Gmail and click the link in the email if the site dynamically changes objects each time I sign into Gmail?

  • I did get gmail through a browser working after restarts and suchlike.

     

    But I do remember the map was a horror story. I'm sure it was about 30 levels deep to actually get to the body of an e-mail. I'm pretty sure I had to go all the way through the map, VERY carefully, and find a couple of identification properties that seemed to indicate session ID's and wildcard them.

     

    This was quite a few versions of Chrome ago, so my map may not still work. Also, that script and the VM which ran it is all zipped away and archived so I can't easily check it for you I'm afraid. (I'm actually on holiday today ... I just remoted into my work machine to check something on e-mail there ...)

     

    But plough through the object map. Looks for long random strings in properties. They tend to be session related and/or generated on the fly.

     

    It may also be worth enabling "find on any level". Or using a top level container and find (or series of finds), rather than a name map.

  • This is not an answer to your question, but rather a suggestion. If you aren't actually testing the Gmail interface, consider accessing Gmail and email contents programmatically. There're third-party email client libraries, such as .NET MailKit, that you can use via CLR Bridge/dotNET. Imho this would be easier than dealing with the UI map.

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    This is not an answer to your question, but rather a suggestion. If you aren't actually testing the Gmail interface, consider accessing Gmail and email contents programmatically. There're third-party email client libraries, such as .NET MailKit, that you can use via CLR Bridge/dotNET. Imho this would be easier than dealing with the UI map.

      • twhitehouse's avatar
        twhitehouse
        Contributor

        I found one other solution that has helped tremendously.  While I do agree with the programmatic approach listed above, it would take some time to work that into the project. 


        So, I am able to bypass a programmatic approach by using GMail short cut keys:

        https://support.google.com/mail/answer/6594?hl=en

         

        I had to turn the short cut keys on as noted under "Shortcuts that need to be turned on" section of that Google page above

         

        I combined that with the "KEYS" command in Test Complete. 

         

        One problem I was having was deleting all messages from my inbox to have a clean start each time the script started up.  So, to do that, I did these 3 commands ( "*" followed by "a" does a select all in GMail.  "#" deletes all selected messages in GMail. )

         

        NameMapping.Sys.browser.BrowserWindow.Keys "*"

        NameMapping.Sys.browser.BrowserWindow.Keys "a"

        NameMapping.Sys.browser.BrowserWindow.Keys "#"

         

        This allows me to not have to worry about the dynamically loaded pages in GMail.

         

        I also set up filters on the account to push all messages not equaling what I wanted to a label that was not the inbox.  This way, only messages I wanted in the inbox would be in the inbox.  All of this combined seemed to simplify what Test Complete had to do.

         

        Hope this helps someone that gets into this situation like I did.

         

    • twhitehouse's avatar
      twhitehouse
      Contributor

      Yes, this was an option I was pondering as well.  I will look into your suggestion.  I am not directly testing the GMail interface.  I just need to get to a link that is inside of an email.  I actually originally started with mail.com.  The mail client does not matter.  I just need to send the email somewhere, open it, find the link and click on it to direct back to our web site.  So, I agree with you at this point after 2 mail clients have posed similar obstacles that we need to find another solution.


      Thanks!

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        I've just resurrected the project I was accessing Gmail with.

         

        I think I would go with the programmatic solution as well. They have totally changed the way everything works since I wrote my script. Two sign-in pages - user ID on the first, password on the second. It only used to be one. Then, once I signed in manually, and checked the mapped objects, everything on the inbox page has changed. Google change things frequently.

         

        If I was to rewrite it now, I'd probably go for programmatric access for long term reliability.

  • I did get gmail through a browser working after restarts and suchlike.

     

    But I do remember the map was a horror story. I'm sure it was about 30 levels deep to actually get to the body of an e-mail. I'm pretty sure I had to go all the way through the map, VERY carefully, and find a couple of identification properties that seemed to indicate session ID's and wildcard them.

     

    This was quite a few versions of Chrome ago, so my map may not still work. Also, that script and the VM which ran it is all zipped away and archived so I can't easily check it for you I'm afraid. (I'm actually on holiday today ... I just remoted into my work machine to check something on e-mail there ...)

     

    But plough through the object map. Looks for long random strings in properties. They tend to be session related and/or generated on the fly.

     

    It may also be worth enabling "find on any level". Or using a top level container and find (or series of finds), rather than a name map.

    • twhitehouse's avatar
      twhitehouse
      Contributor

      Oh boy!  Looks like I have quite a chore ahead of me.  I will do the suggestions you listed.  Thanks for the reply and wish me luck!

      • twhitehouse's avatar
        twhitehouse
        Contributor

        Taking the advice from Colin_McCrae, I had to manually update the Name Mapping file.  So, here is how I fixed this:

         

        1. I did a Check Property to get the path for the I wanted mapped into the Name Mapping file.

        2. I pasted the path into my script and added a ".click" because I wanted to click on the item on the web page ( we will come back to that in a few steps )
        3. I went into the Name Mapping and found the item mapped

        4. I moved it up in the Name Mapping a few levels so that it was under one of the top levels in the mapping.  Basically, for me, this meant bypassing a lot of panels like panelabc, paneldaad, panelwieui, etc.

        5. Once I had the item I wanted mapped above all of those panels, I deleted those panels from Name Mapping

        6. Then, I went back into my script and edited what I pasted with the ".click" on the end from step 1.  I had to remove the ".panelabc", ".paneldaad", and ".panelwieui", etc...  Once I removed all of the extra items in the path in my script, my script clicked on the link from the ".click" I had at the end.

         

        I did not want to write a book, so I left some details out.  The summary is to edit the Name Mapping and move the items up underneath an item that is not changing on the dynamically loaded web page.  Make sure to match that in your script though also.