I’m trying to collect data from 10 textboxes on a webpage. I cannot use Data Scraping because the textboxes are actually dropdowns and I get all the data from the dropdown menu. I’m using Get Text to return the text from the textbox. My issue is that the attribute for the element changes every time (both the value and the length). I thought I had it solved but the length issue occurred today.
For instance, page1 has 3 text boxes:
webctrl name=‘undefined_151’
webctrl name=‘undefined_152’
webctrl name=‘undefined_153’
Page 2 has three text boxes:
webctrl name=‘undefined_79’
webctrl name=‘undefined_80’
webctrl name=‘undefined_81’
Page 3 has three text boxes:
webctrl name=‘undefined_1241’
webctrl name=‘undefined_1242’
webctrl name=‘undefined_1243’
As you can see there is some logic but the numbers change each time. Currently I use the GET ATTRIBUTE activity with this selector:
webctrl name=‘undefined_1’ matching:name=‘fuzzy’ level:name=‘0.1’
to get the lowest value on the page. It seems to work but I don’t know if there is a better way to do that. My issue now is that I use a loop and increment the webctrl name by 1 each loop in a variable called ElementName. This works fine if all the attributes end with 3 numbers because I return the last three numbers in a variable called ElementNum:
ElementName.Substring(ElementName.Length-3)
How can I find how many numbers are in the element name so that no matter whether it is 2, 3, 4, or more it will adjust as necessary?
Edit:
I tried these in an Assign activity but they all return ‘Match’ is a type of Regular Expressions and cannot be used in an expression:
System.Text.RegularExpressions.Match(ElementName,“([0-9]+)”)
System.Text.RegularExpressions.Match(ElementName,“(\d+)”)
System.Text.RegularExpressions.Match(ElementName,“([0-9]+)”).Value
System.Text.RegularExpressions.Match(ElementName,“(\d+)”).Value
I also tried “(\d*)” in a Matches activity and it says ‘Char’ is not derived from ‘System.Text.Regular.Expressions.Match’, as required for the ‘Out’ generic parameter ‘T’ in ‘Interface IEnumerable(OF Out T)’