This is a migrated thread and some comments may be shown as answers.

Unable to perform an ActiveBrowser.Actions on an element

5 Answers 54 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 15 Jan 2015, 06:28 PM
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?

5 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 20 Jan 2015, 01:49 PM
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:

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
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
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
Boyan Boev
Telerik team
answered on 21 Jan 2015, 09:25 AM
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
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
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?
0
Boyan Boev
Telerik team
answered on 09 Feb 2015, 01:24 PM
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:

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
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Eric
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Eric
Top achievements
Rank 1
Share this question
or