How to get the web control values from HTML tag?

In my web application, I am having multiple HTML controls in a page. Now what I am trying to do Is to get all the HTML controls and iterate row by row and get the control or value from HTML.
Suppose the web page has 2 text box, 2 radio button, 1 button and 1 combo box.

Untitled
So here, I need the web control name/id value from the HTML. Could you please help me how I can get these value?

@dev.sam
try Get Attribute Activity

I am using the Get Attribute only. I can get all the information like class,innertext,innerHtml, parent id etcā€¦but failed to get the web control id/name value. i need to fetch the value of web control. Please see the attached image (previous) for reference. Could you please try and let me know what i need to add in my Get Attribute property?

Anybody has some idea about this problem. Kindly share the idea/solution if you came across such type of problem.

Thanks for your help in advance

@dev.sam If you want to retrieve the value of id or name attribute for those elements, then you just need to pass that attribute name for your ā€˜Get Attributeā€™ activity.

image

Let me know if thatā€™s not what you are looking for.

Thanks,
Rammohan B.

Thanks for the reply.

Actually, my requirement is not to get the value inserted in the text field or any web control. Here I am looking for the object name/id of the web control. Similar like when we spy the object and get the name/id value from any automation tool (UFT, Selenium, CodedUI etc.)

Suppose the web page has 2 text box, 1 combo box and 1 submit button. I need to pick all the object name/id value from the HTML control.

Untitled

So here the BOT should give us the number of objects (web components) and its name/id value from the current web page. In our case the result should look like ā€“

HTML Objects available in the web page ā€“ 4 (2 textbox + 1 combo + 1 submit button)
Name/Id of objects ā€“ txtUserID, txtPassword, ddlDomain and btnSubmit

I hope, am able to explain it. Please let me know if you have any doubts/questions.

Thanks
Dev

Hey @dev.sam,

I think i understood what you were looking for.

I am not sure about UFT or CodedUI, But i believe you still have to inspect elements and do something like this,driver.findElements(By.tagName("<tagName>")) which will basically return list of all the elements matching with that tags.

You can use UiExplorer to identify such elements. Basically in your case you can set the target as ā€˜Bodyā€™ of the Html page you are using to get all the Elements available inside the it.

Use this identified selector for ā€˜Find Childrenā€™ activity with the filter as "<webctrl tag="<tagName>"/>". This will return all the elements with that tag and store in an output variable with type as 'IEnumerable<UiElement>'.

Use a ā€˜For Eachā€™ activity to perform your action on each of those identified elements. If you need to get an attribute value for each of those then use ā€˜Get Attributeā€™ under your for each loop.

Let me know if it makes sense. You can attach your html page. May be i can create a simple workflow if you still need it.

Thanks,
Rammohan B.

Hi Rammohan,

Sorry for the delayed reply.

Thanks for the response. You are absolutely right.
I tried the same thing whatever you had suggested but I am unable to fetch the ID and Name value of the HTML controls.

Step 1 ā€“ Open the browser and browse the desired URL
Step 2 - Find the HTML component by using Find Children activity, Here I need all the HTML controls available in that particular page. So here I need text box (username, first name, last name, email and password), Combo box and Submit button.
Step 3 ā€“ Iterate the items (Output variable ā€˜IEnumerableā€™) and get the value out of it by using ā€˜Get Attributeā€™. So here I am looking for HTML control id and name value.

I am looking for the highlighted value.

HTML Page - OpenCart - Account Register

Please, let me know if you need any further information. Please make a sample script and share with me

Thanks in advance.
Dev

Hey @dev.sam,

Tried to implement the workflow that you needed. Attached the same.
OpenCartFindChildren.xaml (19.6 KB)

Let me know if this helps.

Thanks,
Rammohan B.

1 Like

Thanks a lot, Rammohan.

Yes, this is what I was taking about. The workflow works as expected.
I have couple of query regarding the same implementation. After seeing the workflow (Yourā€™s) I had tried myself but failed to understand the ā€œFind Childrenā€ attribute. What I did basically

  1. Dragged the ā€œFind Childrenā€ attribute after open browser
  2. Set the ā€œFilterā€ to ā€œā€
  3. Set the ā€œSelectorā€ manually ā€œā€

But when I execute this, the list of control (count) am getting 1 where as your script gives 6 which is right. I am doing wrong something. If I copied your ā€œfind childrenā€ activity, then I got the right value.

Could you please help me where I am doing the mistake? Kindly review and do suggest me.
Attached the workflow - AutoSequence.xaml (12.9 KB)

Thanks
Dev

Did you change the value of property ā€˜Scopeā€™ to ā€˜FIND_DESCENDANTSā€™? Its ā€˜FIND_CHILDRENā€™ by default.

Find Children ā†’ It identifies the direct children (based on matched filter) only for the selector of find children.

Find Descendant ā†’ It identifies the direct children (based on matched filter) or anything descendant inside the selector.

Thanks,
Rammohan B.

2 Likes

Thank you so much. It is working.

Thanks & Regards
Dev

Hi Rammohan,

Can you decide(or force) Find Children to give UiElements specific atributes?

In the screenshot attached I am getting aaname for the first colomn of the table, but what I really need is to get if for every colomn but the first one.

@Rammohan91, this workflow is not opening for meā€¦ getting error in all activities ā€œThis activity is either missing or could not be loaded properlyā€