FindAll by alternative properties
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FindAll by alternative properties
Hi!
I am using the FindAll method to find all objects of a certain classes on a form. For example:
Object.FindAll('WndClass', 'regexp:^((Button)|(TButton)|(TcxButton)|(TdxBarButton)|(TdxLargeBarButton))$', 20);
But some of the objects that I need are not windows and do not have the WndClass property (for example, BarButtons from DevExpress). Because of this, I have to call FindAll twice, to search by WndClass and ClassName:
Object.FindAll('WndClass', 'regexp:^((Button)|(TButton)|(TcxButton))$', 20);
Object.FindAll('ClassName', 'regexp:^((TdxBarButton)|(TdxLargeBarButton))$', 20);
My question is - it possible to call FindAll once to find objects of the specified alternative properties satisfies the condition. Something like this:
Object.FindAll('WndClass|ClassName', 'regexp:^((Button)|(TButton)|(TcxButton)|(TdxBarButton))$', 20);
Would be grateful for any advice.
Solved! Go to Solution.
- Labels:
-
Desktop Testing
-
Script Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you read the help file for FindAll Method, it shows
You need to pass an array to the first and second parameters
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When passing arrays of properties/values to FindAll, it will search by matching each property to each value. That is, FindAll(['WndClass', 'ClassName'], ['Button', 'TButton'], 20) will find objects that have WndClass='Button' AND ClassName='TButton'.
What I need is the ability to write something like FindAll(['WndClass', 'ClassName'], 'Button', 20) and find objects that have WndClass='Button' OR ClassName='Button'
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From my understanding, to do OR, you'll have to use another FindAll.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, but that's the problem, because calling FindAll twice is too slow
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> is - it possible to call FindAll once to find objects of the specified alternative properties
I am afraid this is not possible. If I remember it right, documentation says that 'or' condition (via regexp) can be used for property values only, but not for the property names. That is why I think that what you are looking for is not possible (at the moment, hopefully) and I do not have at the moment any better idea than two subsequent calls to .FindAll() like you do now.
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
