Forum Discussion

socaltester's avatar
socaltester
Contributor
7 years ago

Unable to Click Dynamic Button Link on Refreshing Page

Windows: 10

TestComplete Web: 12.42

Firefox: 52.0.1

 

I'm experiencing difficulty in writing a Keyword test to click on a link located on dynamic page that refreshes every 15 seconds. In this example the link is a "Back" button. Can someone assist? I've put the source info below and attached the object's property and method information.

 

If possible, I'd like to solve this via Keyword test instead of a written script. The project's base language is VBScript and it needs to work with Firefox 52 and IE 11. I understand that I may need to use "QuerySelector"; however, in a Keyword test I'm unsure how to use it to assist in clicking the dynamic link. 

 

DYNAMIC FULLNAME EXAMPLES:

  1. Sys.Browser("firefox").Page("https://page.com/console/controllers/Counts?which=&rate=&zone=AAA").Panel(0).Panel("in_dialog_bottom").Panel(0).Link("back")
  2. Sys.Browser("firefox").Page("https://page.com/console/controllers/Counts?which=&rate=&zone=AAA&t=1521573680.191").Panel(0).Panel("in_dialog_bottom").Panel(0).Link("back")

 

SOURCE:

 

<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="https://page.com/console/images/OTM_icon1.ico" />
<link rel="stylesheet" href="https://page.com/console/css/pure.min.css">
<link rel="stylesheet" href="https://page.com/console/css/ui.jqgrid.css" />
<link rel="stylesheet" href="https://page.com/console/css/jquery.ui.core.css" />
<link rel="stylesheet" href="https://page.com/console/css/jquery.ui.menu.css" />
<link rel="stylesheet" href="https://page.com/console/css/jquery.ui.autocomplete.css" />
<link rel="stylesheet" href="https://page.com/console/css/jquery.ui.resizable.css" />
<link rel="stylesheet" href="https://page.com/console/css/jquery.contextMenu.css" />
<link rel="stylesheet" href="https://page.com/console/css/jitBase.css" />
<link rel="stylesheet" href="https://page.com/console/css/Spacetree.css" />
<link rel="stylesheet" href="https://page.com/console/css/main-darkly.css" id="theme-css" />

<title id="title">Counts with Refresh Rate: 15 seconds</title>
</head>
<body class="pure-skin-darkly">
<input id="hidden-clipboard-helper" style="position: absolute; margin-top: -1000px"></input>

<!-- Before dialog-main because using absolute position and to hide red if large html in middle -->
<div class="dialog-bottom">
<div id="in-dialog-bottom" class="button-bar">
<div class="text-center">
<a id= "back" class="pure-button" href="https://page.com/console/controllers/HomePanel?zone=AAA">Back</a>
</div>
</div>
</div>

  • Hi,

     

    First of all, the link provided by Marsha_R is definitely worth reading if you haven't already did that.

    Then:

    > I'm experiencing difficulty

    What exactly?

     

    > Can someone assist?

    Quite probably. What assistance you are looking for?

     

    > Keyword test to click on a link

    Can you provide a screenshot of your test?

     

    Without answers to the above questions, I am guessing two possible options:

    a) The target link is not (stably) identified. This can be solved, for example, by proper NameMapping as per the link provided by Marsha and this video: https://support.smartbear.com/screencasts/testcomplete/reliable-tests-for-dynamic-objects/ (from the https://support.smartbear.com/screencasts/testcomplete/ page);

     

    b) The link is identified but is lost after the page refresh because the internal content of the page is generated a-new. In this case you should not store the reference to the once found link, but search for the link just before you need to click it and click immediately. However, there is still a chance that the link will be regenerated before the click action, so, in order to improve test stability and if page refresh is not an absolute requirement for this case, I would recommend to either disable it at all or to make its frequency as low as possible.

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    First of all, the link provided by Marsha_R is definitely worth reading if you haven't already did that.

    Then:

    > I'm experiencing difficulty

    What exactly?

     

    > Can someone assist?

    Quite probably. What assistance you are looking for?

     

    > Keyword test to click on a link

    Can you provide a screenshot of your test?

     

    Without answers to the above questions, I am guessing two possible options:

    a) The target link is not (stably) identified. This can be solved, for example, by proper NameMapping as per the link provided by Marsha and this video: https://support.smartbear.com/screencasts/testcomplete/reliable-tests-for-dynamic-objects/ (from the https://support.smartbear.com/screencasts/testcomplete/ page);

     

    b) The link is identified but is lost after the page refresh because the internal content of the page is generated a-new. In this case you should not store the reference to the once found link, but search for the link just before you need to click it and click immediately. However, there is still a chance that the link will be regenerated before the click action, so, in order to improve test stability and if page refresh is not an absolute requirement for this case, I would recommend to either disable it at all or to make its frequency as low as possible.

     

    • socaltester's avatar
      socaltester
      Contributor

      My apologies for not replying sooner as I was out sick with bronchitis.

       

      It took a couple of things to, I think, consistently select the "Back" button link using TC. Neither of which required "wildcards", which surprised me.  One thing I know helped was adding "VisionOnScreen" = "true" to the set of properties for the object. For some reason, the object would have "VisionOnScreen" = "false" even though one could see it with the human eye. When I would attempt to add "VisionOnScreen" to the set of properties for TC to look for the value would be "false" either right after Object Spy identified the object or after a 15 second refresh, but forcing it to look for a value of "true" solved the issue. Also, timing wasn't an issue as one could wait forever and "VisionOnScreen" would not return to "true".

       

      The other thing that I did, which may have helped, was cleaning out the NameMapping tree of previous major builds where the same object had been identified, but were no longer used do to major and minor UI changes. This may have assisted TC in its ability to run a search or "extended search" for the new version of the object.

       

      Thoughts?