How to get text from dynamic elements

Hi All,
I have to get the text from dynamic Ui Elements.
Here are examples:

  1. Address Lake View 77
    40593 Abcd
    xyz_Tm, Deutschland
    E-Mail abc_12@md.group

Telefon +491234567

  1. Address Hamburg, Hamburg
    Mobil +481234567

  2. Address marktstasse 123
    25345 Halstenbek
    E-Mail xcz.dt@tcom.de

The Contact Information is dynamic. The Ui Element Email andTelephone numbers are not present everytime.
I have tried using Get Text and Get Attribute with Element exists and with regex. Address output is one string “KontaktdatenKontaktdatenGeschäftlichAdresseLake View 7740593 AbcdXyz_Tm, DeutschlandE-Mailrs_19@t_ine.deMobil+1117123456Privat”

Thanks

Hi

This would have helped us to get the attribute value even being dynamic
Didn’t this help or may I know what issue we were facing

@SVa

Get Attribute output is
“AdresseLake View 7740593 AbcdXyz_Tm, DeutschlandEMailrs_19@t_ine.deMobil+1117123456Privat”

everything together in one string. I want get Street Name, PIN, City, Email and Telephone all in seperate variables to ad into excel.

@SVa

What is the attribute you are providing in the Get Attribute Activity?
Also, if the output is in a string then, string manipulation techniques can be applied to extract the required information.
e.g., for extracting email you can use Matches activity in UiPath and there is inbuilt regex for emails in it.
and the phone number always begins with + sign
pin code always have fixed number of digits.

Fine
Got it

Can you help us with what holds what like which is the address part, pin part and even others
And would like to clarify whether the order will same and will all values be provided

@SVa

In Get Attribute i am looking for inner text. The output is a one string

System.Text.RegularExpressions.Regex.Match(contactDetails, "(?<=Adresse).*?(?=E-Mail|Privat)”).Value.Trim

using this regex i am gettting Address.

But its a one String. I cannot seperate Sreet name, number, PIN etc

Yes you can. Have to use proper expression

from below String
“AdresseLake View 7740593 AbcdXyz_Tm,DeutschlandEMailrs_19@t_ine.deMobil+1117123456Privat”

Street name : Lake View 77
PIN : 40593
City: Abcd
State: Xyz_Tm

Its ok if i get PIN and City in one string

in some retrieval cases getting text from webpage will lose spaces, linebreaks (from br,p,div…).
In such scenario getting the info from the inner/outer html attribute and doing the parsing with the help of XML Api methods /LINQ for XML can result to better extractions.

May we ask you to share some more details to the address html element, e.g. screenshot from F12/Webtools? Thanks

1 Like

if i get regex to seperate below string
“AdresseLake View 7740593 AbcdXyz_Tm, Deutschland” into
into
Lake View 77
40593 Abcd
Xyz_Tm, Deutschland

second problem is the Address text is not fix.
I mean sometimes, there is no Street name or City or PIN

@SVa

What about the option suggested by @ppr of using the attribute InnerHTML instead of innerText?

Yes. That is the Problem. Its not taking spaces, or new line

grafik

please give us an expanded screenshot, that we can rely to more details (will see the structure and the text content). But in general it looks good to apply this strategy of extraction. We did sucessfully in the past in production projects and it was working reliable.

Here is the output of Get Attribute with InnerHTML

{
“message”: “<div class="sv9lqc-0 jwKOuC"><h1 class="wnpgbw-0 dOLDSf sv9lqc-3 bpKfht">Kontaktdaten<h2 class="sc-1gpssxl-0 ljRcNB sv9lqc-2 Kduts">Kontaktdaten<h2 class="sc-1gpssxl-0 lcVHKQ">Geschäftlich<div class="styles-grid-grid-72b8c4f4" uipath_custom_id="2"><div class="styles-grid-row-fed1719a x2jri3-0 gJKZmg"><div class="styles-grid-col-545463ec styles-grid-default4-26d4641e styles-grid-confined3-df054b52" id="profile-contact-label-adress">Adresse<div class="styles-grid-col-545463ec styles-grid-default8-6467bca9 styles-grid-confined9-4d3882de"><div data-qa="profile-contact-street-address" uipath_custom_id="5">Am Zehnthof 77<div data-qa="profile-contact-zip-address" uipath_custom_id="4">40593 Düsseldorf<div data-qa="profile-contact-country-province-address" uipath_custom_id="3">Nordrhein-Westfalen, Deutschland<div class="styles-grid-row-fed1719a x2jri3-0 gJKZmg"><div class="styles-grid-col-545463ec styles-grid-default4-26d4641e styles-grid-confined3-df054b52">E-Mail<div class="styles-grid-col-545463ec styles-grid-default8-6467bca9 styles-grid-confined9-4d3882de"><a class="sc-14uud3r-0 jdlQiZ" href="mailto:rfuchs_1998@t-online.de">rfuchs_1998@t-online.de<div class="styles-grid-row-fed1719a x2jri3-0 gJKZmg"><div class="styles-grid-col-545463ec styles-grid-default4-26d4641e styles-grid-confined3-df054b52">Mobil<div class="styles-grid-col-545463ec styles-grid-default8-6467bca9 styles-grid-confined9-4d3882de"><a class="sc-14uud3r-0 jdlQiZ" href="tel:+491789838300">+491789838300<h2 class="sc-1gpssxl-0 lcVHKQ k1isk7-0 gpmazE">Privat<p class="x85e3j-0 lhmgjS y4z6ql-0 ifwEqY z9kru0-0 gDQykP"><svg xmlns="http://www.w3.org/2000/svg\” viewBox="0 0 24 24" width="32" height="32" class="z9kru0-1 fUEkvS"><g fill="none" fill-rule="evenodd"><path d="M0 0h24v24H0z"><path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2zm0 2a8 8 0 100 16 8 8 0 000-16zm1 7v6h-2v-6h2zm0-4v2h-2V7h2z" fill="currentColor" fill-rule="nonzero">Dieses Mitglied hat in diesem Bereich leider noch keine Angaben gemacht.

",
“level”: “Information”,
“logType”: “User”,
“timeStamp”: “11:04:28”,
“processVersion”: “1.0.0”,
“jobId”: “f6656ff1-ba1c-421e-8f3f-90fae614062b”,
“robotName”: “Laptop Sonali”,
“machineId”: 31,
“organizationUnitId”: 1,
“fileName”: “Main”
}

How can i extract the information from above output.
Thanks

perfect
so we do see the identifiers from the data-qa attribute and can use it for the adress parsing.
In case of you are not familiar with XML extractio / retrieval just send me some samples as text and I will so some prototype implementation for you

Here are examples:

Address Lake View 77
40593 Abcd
xyz_Tm, Deutschland
E-Mail abc_12@md.group
Telefon +491234567

Address Hamburg, Hamburg
Mobil +481234567

Address marktstasse 123
25345 Halstenbek
E-Mail xcz.dt@tc.de

i have tried with Deserialize xml but getting error. I am new to this xml part.

we do need the HTML excerpt as we want to process it with XML API. Please copy the snippets from browser / Sourcode and not fromany Logs. Thanks

In this example only Address is there.

In below example there are two phone numbers and Fax number also

have send PM to you