I tried using the coded step below but it fails to compile
HTMLFindExpression expr=new HtmlFindExpression("id=~ScheduledAssetIds","|","class=~arrow");
Element sel=Find.ByExpression(expr);
Manager.ActiveBrowser.Actions.(sel);
Is something that needs to be done before I can perform the action or just can't be done with this way?
My goal is to make a script that can run on the same element on different webpages. Is there a better way to do this?
HTMLFindExpression expr=new HtmlFindExpression("id=~ScheduledAssetIds","|","class=~arrow");
Element sel=Find.ByExpression(expr);
Manager.ActiveBrowser.Actions.(sel);
Is something that needs to be done before I can perform the action or just can't be done with this way?
My goal is to make a script that can run on the same element on different webpages. Is there a better way to do this?
5 Answers, 1 is accepted
0
Hello Eric,
You should choose an action which you want to execute against the element (e.g. Click). Also it should be HtmlFindExpression instead of HTMLFindExpression:
Let me know if this helps.
Regards,
Boyan Boev
Telerik
You should choose an action which you want to execute against the element (e.g. Click). Also it should be HtmlFindExpression instead of HTMLFindExpression:
HtmlFindExpression expr=
new
HtmlFindExpression(
"id=~ScheduledAssetIds"
,
"|"
,
"class=~arrow"
);
Element sel=Find.ByExpression(expr);
Manager.ActiveBrowser.Actions.Click(sel);
Let me know if this helps.
Regards,
Boyan Boev
Telerik
0
Eric
Top achievements
Rank 1
answered on 20 Jan 2015, 04:31 PM
The exact same code compiled and worked the first time but failed to compile the second time after I added some commands using the record feature. There might be a bug in the Test Studio
0
Hi Eric,
I am not able to reproduce such a scenario.
Could you please send us the project which fails to compile so we can debug it and give you a solution.
Hope to hear from you soon.
Regards,
Boyan Boev
Telerik
I am not able to reproduce such a scenario.
Could you please send us the project which fails to compile so we can debug it and give you a solution.
Hope to hear from you soon.
Regards,
Boyan Boev
Telerik
0
Eric
Top achievements
Rank 1
answered on 04 Feb 2015, 09:30 PM
I found it basically, HTMLFindExpression !=HtmlFindExpression
That aside I'm trying to select the encircled DOM element but having a hard time doing so since the ID changes for every page and refresh so far I've tried:
HtmlFindExpression expr = new HtmlFindExpression("class=~schedule-item", "|", "class=~dropdown", "|", "for=~");
Manager.ActiveBrowser.Actions.Click(Find.ByExpression(expr));
This element is located inside a drop down list. How do I select it with Telerik?
That aside I'm trying to select the encircled DOM element but having a hard time doing so since the ID changes for every page and refresh so far I've tried:
HtmlFindExpression expr = new HtmlFindExpression("class=~schedule-item", "|", "class=~dropdown", "|", "for=~");
Manager.ActiveBrowser.Actions.Click(Find.ByExpression(expr));
This element is located inside a drop down list. How do I select it with Telerik?
0
Hi Eric,
Yes you are right, you should use HtmlFindExpression as I mentioned in my last reply.
Regarding the find expression, it is not very reliable in my opinion.
1. I cannot see the element with such classes, please send us a bigger snapshot of the DOM.
2. Are those classes unique (i.e. there is only one element with that class)? If not Test Studio may find another element with the same class. It is better to use unique attributes (e.g. ID, TextContent e.t.c.).
3. It is a good practice to wait some time for that element before you click it:
4. If it is a dropdown you should first locate it, open it and then click on one of its items.
In order to assist you best with the code please grant us an access to the application.
Hope to hear from you soon.
Regards,
Boyan Boev
Telerik
Yes you are right, you should use HtmlFindExpression as I mentioned in my last reply.
Regarding the find expression, it is not very reliable in my opinion.
1. I cannot see the element with such classes, please send us a bigger snapshot of the DOM.
2. Are those classes unique (i.e. there is only one element with that class)? If not Test Studio may find another element with the same class. It is better to use unique attributes (e.g. ID, TextContent e.t.c.).
3. It is a good practice to wait some time for that element before you click it:
HtmlFindExpression expr =
new
HtmlFindExpression(
"class=~schedule-item"
,
"|"
,
"class=~dropdown"
,
"|"
,
"for=~"
);
ActiveBrowser.WaitForElement(expr, 30000,
false
);
Element el = ActiveBrowser.Find.ByExpression(expr);
ActiveBrowser.Actions.Click(el);
4. If it is a dropdown you should first locate it, open it and then click on one of its items.
In order to assist you best with the code please grant us an access to the application.
Hope to hear from you soon.
Regards,
Boyan Boev
Telerik