henry8866 Absent Member.
Absent Member.
847 views

how to find element with partial string

Jump to solution

In browserclick function, how to locate an element based on partial of the text?

BrowserClick("//a[@textContents='ABC']", BUTTON_Left, "Click link");

 

<a data-index="0" href="/xxx" target="_self">
     ABC
     </a>

 

In the above code, it try to find a link with ABC as text, however in my case, the actual text has some invisible space and line breaks (see above html). Is there a way to find the element just using the the partial text ABC? I am using silk performer 17.5

Thanks.

0 Likes
1 Solution

Accepted Solutions
Highlighted
agbykov Absent Member.
Absent Member.

RE: how to find element with partial string

Jump to solution
I used a regular expression and it worked for my case. Therefore, try following:
BrowserClick("//a[@textContents='*ABC*']", BUTTON_Left, "Click link");
1 Reply
Highlighted
agbykov Absent Member.
Absent Member.

RE: how to find element with partial string

Jump to solution
I used a regular expression and it worked for my case. Therefore, try following:
BrowserClick("//a[@textContents='*ABC*']", BUTTON_Left, "Click link");
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.