One of these is a Submit button:
ctl00_ctl00_mastercontent_ContentPlaceHolder1_MainTemplate1_RadDock3664_C_3664_btnnewresource_input
The numbers that typically get changed are "3664".
In the Elements list I right clicked and selected Edit Element.
Find Element is opened after selecting to locate element without connecting.
In the ID row I changed "is exactly" to "matches this regular expression"
? - Should I just replace "3664" with "*" to except multiple characters within the string like this:
ctl00_ctl00_mastercontent_ContentPlaceHolder1_MainTemplate1_RadDock3664_C_3664_btnnewresource_input
ctl00_ctl00_mastercontent_ContentPlaceHolder1_MainTemplate1_RadDock*_C_*_btnnewresource_input
Can the "?" be used in a string to accept 1 character? Do I need to insert the wildcards in brackets?
Find Expressions were also listed in the documentation but their use is a little unclear.
Thanks,
Chris
10 Answers, 1 is accepted
Thank you for your interest in Test Studio and I apologize for the delay in getting back to you on this issue.
Since your application deals with dynamic ID's on a regular basis, it may be worthwhile to consider solution 1 in this article and demote/remove the id property from being used as the default means for creating an elements' primary find expression.
If the id's throughout your application are the only unique attribute associated with their respective element, then I hope you will be content with editing the search logic of every element which contains a dynamic portion in its id. Using your example, the find logic should resemble:
id 'starts with' ctl00_ctl00_mastercontent_ContentPlaceHolder1_MainTemplate1_RadDock
AND
id 'contains' _C_
AND
id 'ends with' _btnnewresource_input
With regards to using 'matches this regular expression', I apologize if our documentation has misled you in any way but 'step 5 - Advanced' in this article contains the only supported operators to be used with that expression. (Note that a * character can only be used at the end of a 'value' to signify a wild card)
Please let me know whether my suggestion helps or if you have any followup questions.
Kind regards,
Mario
the Telerik team
Test Studio Trainings
Hi Mario
I have an element which can anyone of a series of ids .. advFindEFGRP0FFLD0_filterListFLD, advFindEFGRP0FFLD1_filterListFLD, advFindEFGRP0FFLD2_filterListFLD...
What would the wildcard be for the regular expression?
I've tried id=#advFindEFGRP0FFLD?_filterListFLD
Thanks,
dan
You can try this:
ActiveBrowser.Find.ByExpression<HtmlAnchor>(
"id=^advFindEFGRP0FFLD"
);
It will find every element which ID starts with "advFindEFGRP0FFLD".
Let me know if that helps.
Regards,
Boyan Boev
Telerik by Progress
As I cannot rely on the exact id for elements in our application, I tried to edit the element as follows :
1. tagname 'is exactly' a
2. id 'matches this regular expression' "splitbutton-([0-9]+)$"
I gave the wait logic which is
bool expextedValue = true;
Pages.Https1013129.Splitbutton1039Link.Wait.ForCondition((a_0, a_1) => (((ArtOfTest.WebAii.Controls.HtmlControls.HtmlAnchor)(a_0)).IsVisible() == expextedValue), false, null, 30000);
This step failed on running the test as it couldn't find the element.
Then I tried the following method by editing the find logic code as follows
HtmlFindExpression expression = new HtmlFindExpression("id=^splitbutton-([0-9]+)$", "tagname=a");
ActiveBrowser.WaitForElement(expression, 10000, false);
This also didn't work.
Please let me know what I missed in both cases.
Thanks in advance
Renjila
Thank you for sharing details about your difficulties.
Could you please use hash sign (#) in front of the regular expression as this is the supported operator for this kind of identification. I hope this will work for you!
Regards,
Elena Tsvetkova
Progress Telerik
Thank you for your inputs!
Regards,
Renjila
Thank you for getting back to me. I am glad to know the resource was useful for you!
Regards,
Elena Tsvetkova
Progress Telerik
Hi,
I have an id as C1__C2__WORKINGELEMENTS[1].ANSWERS[1].CURRENTVALUEINCLVAT where the C2 part the number can be anything so i wanted to use a better way for identifying the element.
I tried id end with WORKINGELEMENTS[1].ANSWERS[1].CURRENTVALUEINCLVAT and id starts with C1__C*__ but it does not identify. How can I make this work?
Thank you for the details.
There are few options which should cover the described scenario. Please find these below:
- You could modify the find expression for the clause 'id starts with' to use the string partially and set it to 'id contains ~C1__C'.
- If you need to explicitly use 'starts with' that combination, I guess the scenario could be covered with 'id starts with C1__C'.
- And the last option is to use regular expression - to mark a string in Test Studio find expression which will be used as a regular expression, you need to add a hash sign at the beginning. In other words it should look like 'id matches the regular expression #C1__C*__.
I hope any of these will be suitable for you. In case you need further assistance please let me know.
Regards,
Elena Tsvetkova
Progress Telerik