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?
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)