Highlighted
Absent Member.
Absent Member.
1726 views

[UFT] Get text into DIV through HTML tag

Hi,
I have this element.

I would like to take the text into WebElement object so i wrote:
[code]
txt = Browser("YA Web").Page("YA Web").WebElement("html tag:=CAPTION").GetROProperty("innerText")
[/code]
I skipped the WebTable object because in the repository the WebElement was inserted as child of YaWeb Page.

UFT not finds this object into my application:
"The "[WebElement]" object's description matches more than one of the object currently displayed in your application. etc...."

Why?

Thanks a lot.

0 Likes
6 Replies
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: [UFT] Get text into DIV through HTML tag

The html tag property alone isn't unique to identify the object. There are more than one object with that description html tag= CAPTION on the page. You have to add more to the description to uniquely identify the object.

_____________________
Rajkumar Rajangam
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: [UFT] Get text into DIV through HTML tag

Hi, I think that there is ambiguous situation after that I wrote the post.
Unfortunately the description of this object is dynamic, because there is a dynamic date string.
How can I identify uniquely this object?

Thanks a lot.

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: [UFT] Get text into DIV through HTML tag

Do you really need to use DP for this?  Add to your OR and apply the myriad of object identification methods UFT provides - i.e. multiple properites, coupled with reg expressions, VRIs, or even indexing if it comes down to it.

 

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: [UFT] Get text into DIV through HTML tag

You can add regular expressions to match the dynamic characters.

For ex:

WebElement("html tag:=CAPTION.*")

CAPTION.* - this would match any number of characters after the word CAPTION


Accept as solution/Give Kudos to the author if the piece of information answered/helped you to solve your problem.
All the thoughts here are mine not related to my employer nor anyone.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: [UFT] Get text into DIV through HTML tag

You have just pointed out the html tag. Which usually in a webpage, the same html tag will be present in many places throughout the dom. Make it unique by adding the html id like 

txt = Browser("YA Web").Page("YA Web").WebElement("html tag:=CAPTION","html id:=.*caption.*").GetROProperty("innerText")

or index it like

txt = Browser("YA Web").Page("YA Web").WebElement("html tag:=CAPTION","index:=0").GetROProperty("innerText")

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: [UFT] Get text into DIV through HTML tag

I have some problem with this way because the description of object is dynamic.

I removed description properties so the ObjectRepository can identify it in application.

So I get the text throught .Object.innerText

Now it works!

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.