Interacting with HTML DOM objects via javascript or Ajax in TC 14
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interacting with HTML DOM objects via javascript or Ajax in TC 14
I'm new to testcomplete. We have an area in our web app that is extremely difficult for testcomplete recorder to understand. We have a hidden ul that become un-hidden on a button click. Each list element has an input checkbox. I'm attempting to select all items in the list and check each item. The recorder is struggling so I thought we could just inject some javascript or ajax to make it happen.
In our selenium/.NET C# solution I just executed some ajax like so: $("div[aria-checked*= 'false'] span.dx-checkbox-icon").click()
I would like to execute something similar. Below is an example of the hidden ul.
<ul class="dx-treeview-node-container" role="group"> <li class="dx-treeview-node dx-treeview-item-with-checkbox dx-treeview-node-is-leaf" data-item-id="0" role="treeitem" aria-label="Period Index" aria-expanded="true" aria-level="1" aria-selected="false"> <div role="checkbox" class="dx-checkbox dx-widget" aria-checked="false"> <input type="hidden" value="false"> <div class="dx-checkbox-container"> <span class="dx-checkbox-icon"></span> </div> </div> <div class="dx-item dx-treeview-item" aria-selected="false"> <div class="dx-item-content dx-treeview-item-content"> <span>Period Index</span> </div> </div> </li> <li class="dx-treeview-node dx-treeview-item-with-checkbox dx-treeview-node-is-leaf" data-item-id="1" role="treeitem" aria-label="Period Begin" aria-expanded="true" aria-level="1" aria-selected="false"> <div role="checkbox" class="dx-checkbox dx-widget" aria-checked="false"> <input type="hidden" value="false"> <div class="dx-checkbox-container"> <span class="dx-checkbox-icon"></span> </div> </div> <div class="dx-item dx-treeview-item" aria-selected="false"> <div class="dx-item-content dx-treeview-item-content"> <span>Period Begin</span> </div> </div> </li> </ul>
There are about 45 items in the list.
My goal is to add a short script snippet to a keyword test to set the inputs to 'checked'. Any help would be great. thanks!
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This sounds like something to talk to Support about. Here's the link:
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please excuse my brevity...
> I'm new to testcomplete.
TestComplete provides documentation of extreme quality that is definitely worth carefull reading for details. This is a significant difference from a lot of free tools and libraries, please consider this.
> I just executed some ajax [...]
Your code sample is not an Ajax call but a regular call via jQuery (most probably).
> I would like to execute something similar.
TestComplete supports execution of the custom script code within web page. See https://support.smartbear.com/testcomplete/docs/app-testing/web/common-tasks/javascript.html for more details and code samples.
> [...] to set the inputs to 'checked'.
You may either adopt your jQuery code to TestComplete as described in the referenced help topic, or use TestComplete's .FindAllChildren() method to find all required web elements and iterate through them.
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you everyone!
Hi @knudmt , were you able to use Alex's advice?
Also, I couldn't locate you support ticket, please let us know if you managed to resolve your situation. Thank you.
Sonya Mihaljova
Community and Education Specialist
