cancel
Showing results for 
Search instead for 
Did you mean: 

Interacting with HTML DOM objects via javascript or Ajax in TC 14

SOLVED
Highlighted
Regular Visitor

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!

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Interacting with HTML DOM objects via javascript or Ajax in TC 14

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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

3 REPLIES 3
Highlighted
Community Hero

Re: Interacting with HTML DOM objects via javascript or Ajax in TC 14

This sounds like something to talk to Support about.  Here's the link:

https://support.smartbear.com/message/?prod=TestComplete

Highlighted
Community Hero

Re: Interacting with HTML DOM objects via javascript or Ajax in TC 14

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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Community Manager

Re: Interacting with HTML DOM objects via javascript or Ajax in TC 14

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

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors