NameMapping & Object Browser for Dynamically Created Object
Hi,
I have a newbie question about how to use NameMapping and Object Browser properly.
I understand that when I start Recording, TC will "remember" all objects on my webpage, what I type in the text boxes, and what buttons do I click. So, when I playback, TC knows about all those objects and which one to Click().
I have a blank website with one "ADD" button..
- When I click that "ADD" button once, a text-box and a "Submit" button will appear, so user can write e.g. "Hello1" and click "Submit".
- When I click that "ADD" button once again, a second text-box and a second "Submit" button will appear, so user can write e.g. "Hello2" and click "Submit".
- And so on ...
If I don't use Recording functionality, I would
- Explore the DOM and find the parent.
- After I Click() that "ADD" button for the first time, I would see the first child. That first child will have two children (one for the text-box and another one for the "Submit" button).
var parent = Page.QuerySelectorAll(CSSselector);
... //Click() ADD Button; var textbox = parent.children.item(0).QuerySelector(XXX); // Find the 1st textbox var submit = parent.children.item(0).QuerySelector(YYY); //Find the 1st submit button
- After I Click() that "ADD" button for the second time, I would see the second child. That second child will have two children (one for the text-box and another one for the "Submit" button).
var parent = Page.QuerySelectorAll(CSSselector);
... //Click() ADD Button;
... //Click() ADD Button; var textbox = parent.children.item(1).QuerySelector(XXX); //Find the 2nd textbox var submit = parent.children.item(1).QuerySelector(YYY); //Find the 2nd submit button
If I want to click that ADD button 100 times, then I could easily find the 100th text-box and submit button by
var textbox = parent.children.item(99).QuerySelector(XXX);
var submit = parent.children.item(99).QuerySelector(YYY);
Now if I want to use Recording functionality and take advantage of NameMapping and Object Browser functionalities, How can I do that?
TC won't know what and where is the 100th Submit button object, unless I start recording and click that "ADD" 100 times until the 100th Submit button appears and TC remember and put that object in the NameMapping & Object Browser (I don't think that is an efficient way of creating automation script :smileytongue:).
Is there any way to create a logic in the NameMapping & Object Browser, so I don't need to record and click 100 times ?
Thank You.