Forum Discussion
In case it's needed, this is the code:
var item = this.page.FindElement("//span[@data-testid='" + dataTestIdString + "']");
if(item.Parent.attributes.aria_selected == true)
{ ... do stuff
For all other attribute accesses, this code works but the "attributes" property doens't exist on the Parent
Hi,
> For all other attribute accesses, this code works but the "attributes" property doens't exist on the Parent
Are you saying that for 'item' element statement, for example, item.Parent.FullName returns some value and only item.Parent.attributes evaluates to null?
If the above is true, then this might be a problem in TestComplete.
If item.Parent contains only native html properties or evaluates to null, then it might be a case that the span you are looking for was excluded from objects hierarchy in TestComplete (https://support.smartbear.com/testcomplete/docs/app-testing/web/general/object-identification/tree-model-elements.html) and thus FindElement() returned native DOM element but not its TestComplete wrapper (as this happens usually).
As a kind of workaround I may suggest:
a) either try to use native DOM methods to get item's parent; or
b) try to search for the li element that has required child span element and work with found li element. Consider https://copyprogramming.com/howto/how-select-a-parent-node-with-xpath as an example of possible search.
Hope this will help.
Related Content
- 11 years ago