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

Right Click scenario- element not found

10 Answers 269 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tracy
Top achievements
Rank 1
Tracy asked on 30 Mar 2012, 08:05 PM

Hi I am new to Telerik test studio and our team is interested in this product to automate our Silverlight Application.

Today I use Telerik test studio to create a simple web test to record our Silverlight UI, but it doesn’t work often for the right click.

Simple scenario:

  1. Login to UI
  2. Search the address and press enter key
  3. Right click the location inside the triangle area

 

I create a simple test and run it several times and it works.  Later, I run it again. It fails.  I even set up the time stamp to allow it to have much time to do the right click, but it doesn’t work and the test fails due to “element not found” .

I find Telerik test studio can generate C# code and I run it again. The same issue happens.

Is there any way to investigate this right click issue? 

Thanks,

10 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 30 Mar 2012, 08:50 PM
Hello Tracy,

Thank you for taking the time to evaluate Test Studio. I am certain whatever the problem is we'll be able to figure it out and solve it.

First I'd like to understand how you have implemented this Right Click in your test. The reason I ask is because Test Studio does not automatically record a Right Click mouse event. It only automatically records the Left Click (and then only single clicks, not double clicks). You have to use our Element Menu to add a Mouse Right Click step.

The next time it fails please try to send us as much information as you can about what happened when it failed. Especially useful to us is the exported test failure details as mentioned in the first bullet point here.

Regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tracy
Top achievements
Rank 1
answered on 30 Mar 2012, 09:41 PM

Hi Cody,

Thanks for your information. It doesn’t work if I use the edit menu you provided. I find Telerik test studio generates the following code.  Does it mean it really has the right click action?  It seems to me the answer is yes, but it doesn't do the right click action sometimes and it causes the "element not found".  In this case, how can I force it to do the right click sucessfully?

 

Pages.Sprint2.SilverlightApp.Item7474Graphicelement.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 52, 45, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));


public ArtOfTest.WebAii.Silverlight.UI.Control Item7474Graphicelement
                {
                    get
                    {
                        return Get<ArtOfTest.WebAii.Silverlight.UI.Control>("XamlTag=map", "automationid=AtMap", "|", "XamlPath=/grid[0]/grid[name=RootElement]/canvas[0]/grid[0]/layercollectioncanvas[" +
                                "0]/layercanvas[6]/graphicelement[233]");
                    }
                }

0
Cody
Telerik team
answered on 30 Mar 2012, 11:50 PM
Hi Tracy,

The code snippet does look like a Right Click command, so yes I do agree with you.

Why the click sometimes errors out with "element not found" is impossible for me to say. I would need to be able to see the problem happening first hand. A good starting point is if you can export the step failure details, as discussed in the first bullet, and send me that zip file for analysis.

Kind regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Tracy
Top achievements
Rank 1
answered on 02 Apr 2012, 09:36 PM

Hi Cody

Thanks for your information. This time I create a Telerik web test in VSTS 2010, record it and run it. It passes. But If I convert it to the coded step (last step) and run it again. It fails. Sometimes I don't convert it to the coded step and it fails too.

I copy the log file as follows.  Thanks !

----------------------------------------------------------
'4/2/2012 11:57:16 AM' - Using 'InternetExplorer' version '8.0' as default browser.
'4/2/2012 11:57:21 AM' - 'Pass' : 1. Navigate to : 'our URL'
'4/2/2012 11:57:25 AM' - 'Pass' : 2. LeftClick on Item0Textboxview
'4/2/2012 11:57:28 AM' - 'Pass' : 3. Type 'AA' into TextUserTextbox
'4/2/2012 11:57:32 AM' - 'Pass' : 4. LeftClick on Item1Textboxview
'4/2/2012 11:57:33 AM' - 'Pass' : 5. Type 'AA' into TextPasswordPasswordbox
'4/2/2012 11:57:34 AM' - 'Pass' : 6. Click OKButtonButton
'4/2/2012 11:57:42 AM' - 'Pass' : 7. LeftClick on Item0Textboxview0
'4/2/2012 11:57:43 AM' - 'Pass' : 8. Type '8' into SearchTextSearchtextblock
'4/2/2012 11:57:45 AM' - 'Pass' : 9. Press Back
'4/2/2012 11:57:46 AM' - 'Pass' : 10. Type '94539' into SearchTextSearchtextblock
'4/2/2012 11:57:47 AM' - 'Pass' : 11. Press Return
'4/2/2012 11:57:50 AM' - 'Pass' : 12. LeftClick on x94539Textblock
'4/2/2012 11:57:54 AM' - 'Pass' : 13. LeftClick on ImgCloseImage
'4/2/2012 11:58:05 AM' - 'Fail' : 14. [WebTest1_CodedStep] : @"RightClick on Item7473Graphicelement", RequiresSilverlight = true
------------------------------------------------------------
Failure Information:
~~~~~~~~~~~~~~~
Exception thrown executing coded step: '[WebTest1_CodedStep] : @"RightClick on Item7473Graphicelement", RequiresSilverlight = true'.
InnerException:
ArtOfTest.Common.Exceptions.FindElementException: Element Not found!
   at ArtOfTest.Common.WaitSync.CheckResult(WaitSync wait, String extraExceptionInfo)
   at ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout, WaitResultType errorResultType)
   at ArtOfTest.WebAii.Silverlight.VisualWait.ForExistsInternal(Int32 timeout, Boolean invertCondition)
   at ArtOfTest.WebAii.Silverlight.VisualWait.ForVisible(Int32 timeout)
   at ArtOfTest.WebAii.TestTemplates.XamlElementContainer.Get(XamlFindExpression expr, Boolean waitOnElement, Int32 timeout)
   at ArtOfTest.WebAii.TestTemplates.XamlElementContainer.Get(XamlFindExpression expr)
   at ArtOfTest.WebAii.TestTemplates.XamlElementContainer.Get[TControl](XamlFindExpression expr)
   at ArtOfTest.WebAii.TestTemplates.XamlElementContainer.Get[TControl](String[] clauses)
   at Atlas.Pages.Sprint2Page.SilverlightAppElement.get_Item7473Graphicelement() in C:\Code\QA\Test\Pages.g.cs:line 207
   at Atlas.Atlas.WebTest1.WebTest1_CodedStep() in C:\Code\QA\WebTest1.tstest.cs:line 77
------------------------------------------------------------
'4/2/2012 11:58:05 AM' - Detected a failure. Step is marked 'ContinueOnFailure=False' aborting test execution.
------------------------------------------------------------
'4/2/2012 11:58:05 AM' - Overall Result: Fail
'4/2/2012 11:58:05 AM' - Duration: [0 min: 48 sec: 431 msec]
------------------------------------------------------------
'4/2/2012 11:58:06 AM' - Test completed!

Coded Step: really has right click.
Pages.SilverlightApp.Item7473Graphicelement.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 48, 43, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));

0
Cody
Telerik team
answered on 05 Apr 2012, 12:47 AM
Hi Tracy,

Until I can reproduce this problem I cannot determine what may be causing it. I've already tried converting a right click test step to code and it always works perfectly for me. Can I access your application directly somehow? If this information is too sensitive for the general public, feel free to file a new support ticket on this issue. Only the technical support team here and you can see the information in private support tickets.

Regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Shaik
Top achievements
Rank 1
answered on 16 Apr 2019, 12:56 PM
Hi I am using telerik test studio ultimate in this i am coding for one scenario in this i need to  write a code for right click i using the above one but it's not working can someone help me in this. Thanks. 
0
Shaik
Top achievements
Rank 1
answered on 16 Apr 2019, 12:57 PM

I am using telerik test studio ultimate in this i am writing code for of the Scenario in this i want rightclick option for this i have suing the above code but it is not working. can some one help me in this. 

Thanks in advance. 

0
Elena
Telerik team
answered on 17 Apr 2019, 03:52 PM
Hello Shaik,

Can you please share additional details on the encountered errors? 

As far as I understand you need to handle a right click action in code - what is the code that you have used? And what is the error thrown when executing the test? 

You can share the step failure details generated after a failed test run (you can use the Export button in the Failure tab) and send these zipped along with the code from the coded step - that way I will be able to better understand what might have gone wrong. 

Apart from that, you can elaborate some further details on the scenario you need to cover and what is the reason to decide the coded approach. The reason I am asking, is that Test Studio provides you the right click in the Quick actions menu under Mouse Actions - have you tried that one? Did you face any troubles with the recorded step and thus switched to the coded solution? 

I am looking forward to hearing back from you. 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Shaik
Top achievements
Rank 1
answered on 28 Apr 2019, 10:39 AM

Scenario:- I am adding data and displaying that in the grid here I need to right click on the data that I have just added.

for which I have written the code is not working.

Here one more thing is data in the grid uses two class one alternate and another is non-alternate classes for more information I am sharing the screenshots please find them in the attachment.

 

Thanks,

Shaik Sohail

PWC Bangalore.

0
Elena
Telerik team
answered on 01 May 2019, 02:11 PM
Hi Shaik,

Thank you for getting back to me with additional details. 

I reviewed the code you have prepared to decide on which element you need to perform the right click. Still I am not sure what the is the failure you encountered and how the application's elements are structured, though there are few things to mention. 

It seems that you need to find on page the div element with the class which ends on alternate - however, the current code will fail at the line, which defines the HtmlDiv str, if there is any case, when the page does not contain an element with that class. That way, the execution will never proceed further to the if..else statement. 

Then, you probably want to compare the class name of that located HtmlDiv str with the string you had defined. Though, the used str.ToString(); will certainly not return the class name. 

The way you compare strings in the condition part of the if..else block will probably also not return what you expect it to return. Here are some guidelines on the topic how strings are compared in C#. 

I noticed you are using the tilde (~) sign in the class name to define an element - this indicates that the class should contain the mentioned string. If leaving the code as it is at its current state, defining the myDiv ​in the else block, will point to all the div elements on page with any of the two classes, we are focused on. 

Having that said, I am still not sure what is the scenario you need to cover and what is the failure information when you try to execute the test. Therefore, if you need additional assistance on the case, I will appreciate if you can share some details on the below topics: 

- Which is the element you need to right click on - the one, which contains 'alternate' in its class name, or the one, which doesn't? 
- How do you decide which of the two elements should be right clicked? 
- How these elements appear and are listed in the DOM tree? Are these always grouped like this? 
- Can you please execute the test and collect the step failure details - you can use the Export button to get the necessary data zipped and send it via this thread. 

I hope the above will help you sort out what still needs to be adjusted. Please, elaborate on the mentioned topics, if you will need additional assistance on the case. Thanks in advance. 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Tracy
Top achievements
Rank 1
Answers by
Cody
Telerik team
Tracy
Top achievements
Rank 1
Shaik
Top achievements
Rank 1
Elena
Telerik team
Share this question
or