Forum Discussion

knudmt's avatar
knudmt
Regular Visitor
5 years ago

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!

  • 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.

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    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.

     

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      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.