Forum Discussion
The reason I said to do this,
let headerItems = headerInputs.FindAll('type','*',5000);
Log.Message("Number of items: " & UBound(headerItems))
Is so that I can see the number of items being returned by the FindAll method, without performing toArray.
Is there any object called 'type'?
The example that I provided, searches for this (ObjectType = Button) -
For reference, use any object name as shown in green, followed by a matching property value as shown in orange
Just tried FindAll with Enabled=True. The same result.
- rraghvani13 days ago
Champion Level 3
Could you create a new project and select JavaScript as the language (or convert the code and use VBScript). Using Chrome, navigate to https://www.w3schools.com/css/css3_buttons.asp and run the following code,
function GetAllButtons() { var browser = Sys.Browser("chrome"); var page = browser.Page("https://www.w3schools.com/css/css3_buttons.asp").Panel(2).Panel(0).Panel("belowtopnav").Panel(0).Panel("main"); var buttons = page.FindAll("ObjectType", "Button", 1); Log.Message(`Number of buttons on page ${buttons.length}`); }
Does it work, and does it return 56 buttons? I just want to eliminate and ensure that FindAll method is working as expected, before proceeding to the next step.
- pkudrys13 days agoFrequent Contributor
So, what happens is, that your code works, as expected. However, it fails in case there is used an Alias element as a parameter.
It seems to me as a TC problem? Or is there another way how to get an array of items from an alias element, whose xpath points to multiple elements?
- rraghvani13 days ago
Champion Level 3
Using the code example that I had provided i.e. GetAllButtons(), the following line of code
browser.Page("https://www.w3schools.com/css/css3_buttons.asp").Panel(2).Panel(0).Panel("belowtopnav").Panel(0).Panel("main");
matches with,
Name mappingName mapping and aliases. Note, the that hierarchy structure is kept the same as shown in the Object Browser.I can use the mapped object like so,
function GetAllButtonsAliases() { var buttons = NameMapping.Sys.browser.pageCssButtons.panelCss.panelCss.panelBelowtopnav.panelCss.panelMain.FindAll("ObjectType", "Button", 1); Log.Message(`Number of buttons on page ${buttons.length}`); }
Or via the the aliases name,
function GetAllButtonsAliases() { var buttons = Aliases.browser.pageCssButtons.panelMain.FindAll("ObjectType", "Button", 1); Log.Message(`Number of buttons on page ${buttons.length}`); }
They all produce the same results,
The difference, is that I'm looking for the criteria where ObjectType equals Button, in panelMain. Whereas, you are looking in button and this will return 1 object. You need to ensure you are finding the appropriate "children" within the "parent" node.
Using XPath in name mappingUsing function