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.
So here, I need the web control name/id value from the HTML. Could you please help me how I can get these value?
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?
@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.
Let me know if thatās not what you are looking for.
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.
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.
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 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.
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
Dragged the āFind Childrenā attribute after open browser
Set the āFilterā to āā
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)
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ā