Forum Discussion
HKosova
Alumni
14 years agoHi Gerhardt,
>>
We added a "qaid" (quality assurance ID) property, which can be seen with F12 (Tools) in IE or Firebug in Firefox, but not by TestComplete's Object Spy.
<<
Yes, custom attributes aren't displayed in the Object Spy, neither they are displayed on the root level of DOM property inspectors in Firebug and Chrome Developer Tools. This is because they aren't DOM properties. In the Object Spy, as well as in Firebug and Chrome DOM inspectors, you can access custom attributes through the attributes property.
However, in TestComplete scripts, custom attributes can be accessed directly using the dot syntax:
You can also use custom attributes when searching for objects using the Page.FindChild, Page.NativeWebObject.Find and Page.EvaluateXPath methods, in the same way you would use standard DOM properties like id or innerText.
For example, you can locate your SPAN element by the qaid value in one the following ways:
or, using EvaluateXPath:
>>
A colleage suggested using EvaluateXPath, so I tried this:
var contentPanel = this.pageObj.EvaluateXPath("//*[@qaid=’Site Photograph’]");
No luck
<<
The EvaluateXPath method returns an array of found objects, even if there's a single object. Also, it's a Variant (VBScript-format) array, so you also need to convert it to a JScript array, like in my example above. Please see the EvaluateXPath method description for details.
I hope this answers your questions!
>>
We added a "qaid" (quality assurance ID) property, which can be seen with F12 (Tools) in IE or Firebug in Firefox, but not by TestComplete's Object Spy.
<<
Yes, custom attributes aren't displayed in the Object Spy, neither they are displayed on the root level of DOM property inspectors in Firebug and Chrome Developer Tools. This is because they aren't DOM properties. In the Object Spy, as well as in Firebug and Chrome DOM inspectors, you can access custom attributes through the attributes property.
However, in TestComplete scripts, custom attributes can be accessed directly using the dot syntax:
contentPanel.qaid
You can also use custom attributes when searching for objects using the Page.FindChild, Page.NativeWebObject.Find and Page.EvaluateXPath methods, in the same way you would use standard DOM properties like id or innerText.
For example, you can locate your SPAN element by the qaid value in one the following ways:
var contentPanel = this.pageObj.FindChild("qaid", "Site Photograph", 100 /* search depth */);
var contentPanel = this.pageObj.NativeWebObject.Find("qaid", "Site Photograph", "span");
or, using EvaluateXPath:
");
arr = new VBArray(arr).toArray();
var contentPanel = arr[0];
>>
A colleage suggested using EvaluateXPath, so I tried this:
var contentPanel = this.pageObj.EvaluateXPath("//*[@qaid=’Site Photograph’]");
No luck
<<
The EvaluateXPath method returns an array of found objects, even if there's a single object. Also, it's a Variant (VBScript-format) array, so you also need to convert it to a JScript array, like in my example above. Please see the EvaluateXPath method description for details.
I hope this answers your questions!