Sometimes, 'click' action doesn't work

Ranorex Spy, Recorder, and Studio.
Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Sometimes, 'click' action doesn't work

Post by Florian » Mon Aug 27, 2012 1:39 pm

I am encountering a very disturbing issue.

I created a web test on the following French website: http://www.ldlc-lyon.com
The test is very simple: 5 iterations of click. It is run twice an hour and the results will be stored in a database to check performance.

The issue I am dealing with is that regularly the 'click' action doesn't work. I can see the mouse moving onto the link, but nothing else happens. Here is the code used:

Code: Select all

Public Sub ChoixUnivers()
	Report.Log(ReportLevel.Info,"Interne", "Récupération des univers dans une liste", repo.LDLClyon.PiecesInfo)
	Dim objList As IList(Of Ranorex.ATag) = repo.LDLClyon.Pieces.FindDescendants(Of Ranorex.ATag)()
	Randomize()
	Dim iRandom As Integer = CInt(Int(objList.Count * Rnd()))
    Report.Log(ReportLevel.Info, "Mouse", "Choix de l'univers " & objList(iRandom).InnerText, repo.LDLClyon.PiecesInfo)
    objList(iRandom).MoveTo()  'line added to try to solve the issue
    objList(iRandom).Click()
    repo.LDLClyon.Self.WaitForDocumentLoaded()
End Sub
As you can see, I had only the 'click' action and added the 'MoveTo' action. But it didn't solve the problem.
Do you have any idea of what could happen?

I can send you the whole test suite if you think it might help.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Sometimes, 'click' action doesn't work

Post by Support Team » Mon Aug 27, 2012 2:15 pm

Hi,

What you can also try is the following:
//instead of:
    objList(iRandom).MoveTo()  'line added to try to solve the issue
    objList(iRandom).Click()
//use just this:
    objList(iRandom).MoveTo()  'line added to try to solve the issue
    Mouse.Click()
Which Ranorex version are you using?

Regards,
Markus
Ranorex Support Team
.
Image

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Sometimes, 'click' action doesn't work

Post by Florian » Mon Aug 27, 2012 2:20 pm

I will try your code and keep you informed if this is better.
I am using the latest version: 3.3.1.18438

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Sometimes, 'click' action doesn't work

Post by Florian » Tue Aug 28, 2012 8:26 am

There are still some problems.
I've just added a 'Wait' command between the 'MoveTo' and 'Click' actions.

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Sometimes, 'click' action doesn't work

Post by Florian » Tue Aug 28, 2012 10:22 am

The 'Wait' command does not change anything. Sometimes the test does not click even if the mouse is on the link ... I can share the Test Suite with you.

EDIT : I've just seen something. When I click on the top-left logo to go on the home page, the page was scrolled down a bit. The mouse moved on the link and approximately at the same time the home page appears. Thus, the mouse was not on the link.

I don't know if you understood what I mean.
Do i have to add more 'Delay' actions?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Sometimes, 'click' action doesn't work

Post by Support Team » Tue Aug 28, 2012 2:13 pm

Hi,

Yes, you can try to add a Delay before the mouse move action, what you can also try is to add a Validate.Exists(...) before you execute the MoveTo() respectively the "objList(iRandom).Click()":
//just:
Validate.Exists(objList(iRandom)) 
//then:
objList(iRandom).Click()
Regards,
Markus
Ranorex Support Team
.
Image

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Sometimes, 'click' action doesn't work

Post by Florian » Tue Aug 28, 2012 2:24 pm

Thank you for your help.
With your code, the third iteration fails:

Code: Select all

00:20.978 
Error 
     Module 
Module execution was aborted because a validation step has failed. Element '{ATag:Portables}' does not exist (element is not valid). 
     Show/Hide Stacktrace
à Ranorex.Validate.IsTrueInternal(Boolean condition, String message, Options options, RepoItemInfo itemInfo) à Ranorex.Validate.Exists(Element element, String message, Options options) à LDLClyon.LDLClyon.NavigationProduit.ChoixUnivers() à LDLClyon.LDLClyon.NavigationProduit.Run() à Ranorex.Core.Testing.TestSuiteModule.RunInternal(DataContext parentDataContext)
But this is really weird because the ATag is always visible, it is part of the menu at the top of the website...

I run the test another time:
Iteration 1 => 00:01.725 Success Validation Element '{ATag:Réseaux}' does exist.
Iteration 4 => 00:30.293 Error Module Module execution was aborted because a validation step has failed. Element '{ATag:Réseaux}' does not exist (element is not valid).

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Sometimes, 'click' action doesn't work

Post by Support Team » Tue Aug 28, 2012 3:22 pm

Hi,

The error message stated that the specific element was not valid, which means that Ranorex was able to find the element but before Ranorex was able to click on it the element was newly created and therefore the error was thrown as the original element did no longer exist.
In order to overcome the issue I would add all elements to the repository or I would save the RxPaths to the elements into an IList and then I would create an Adapter just right before you want to execute the click with the specific RxPath.

Regards,
Markus
Ranorex Support Team
.
Image

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Sometimes, 'click' action doesn't work

Post by Florian » Tue Aug 28, 2012 3:45 pm

I do not have create Adapters yet, so please tell me how can I do that.
It will be difficult to add the elements in the repository because I am choosing a link between 15, then another link from the first one among lots of them, and the same a third time. Therefore I have lots of final links :?

I guess the best solution would be the second one: save the RxPaths of the elements into an IList and create an Adapter.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Sometimes, 'click' action doesn't work

Post by Support Team » Wed Aug 29, 2012 3:42 pm

Hello,

To create Adapters maybe the following link can help you.
Create Adapters to Access More Properties and Methods

Regards,
Bernhard
Ranorex Support Team
.
Image

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Sometimes, 'click' action doesn't work

Post by Florian » Fri Aug 31, 2012 8:19 am

Thank you for your help.

I changed the code but the problem remains :(
Report.Log(ReportLevel.Info,"Interne", "Récupération des catégories dans une liste", repo.LDLClyon.ListingCategoriesInfo)
Dim objList As IList(Of Ranorex.ATag) = repo.LDLClyon.ListingCategoriesInfo.CreateAdapters (of Ranorex.ATag)
Randomize()
Dim iRandom As Integer = CInt(Int(objList.Count * Rnd()))
Report.Log(ReportLevel.Info, "Mouse", "Choix de la catégorie " & objList(iRandom).InnerText, repo.LDLClyon.ListingCategoriesInfo)
Validate.Exists(objList(iRandom))
objList(iRandom).Click(Location.UpperCenter)
repo.LDLClyon.Self.WaitForDocumentLoaded()
Here is what I get:
Module execution was aborted because a validation step has failed. Element '{ATag:Jeux Vidéo}' does not exist (element is not valid).
Show/Hide Stacktrace
à Ranorex.Validate.IsTrueInternal(Boolean condition, String message, Options options, RepoItemInfo itemInfo) à Ranorex.Validate.Exists(Element element, String message, Options options) à LDLClyon.LDLClyon.NavigationProduit.ChoixUnivers() à LDLClyon.LDLClyon.NavigationProduit.Run() à Ranorex.Core.Testing.TestSuiteModule.RunInternal(DataContext parentDataContext)

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Sometimes, 'click' action doesn't work

Post by Support Team » Mon Sep 03, 2012 10:38 am

Hello,

That is unfortunately not what I meant.
Here is a basic code of what should work in your case, but please keep in mind that you have to create the adapters only one another shortly before you want to use it:
Dim yourRepoItem As Form = repo.YourItem
            
            Dim allATags As IList(Of Ranorex.ATag) = yourRepoItem.FindDescendants(Of Ranorex.ATag)()
            Dim allPaths As IList(Of String) = New List(Of String)
            
            Dim aTag As Ranorex.ATag
            
            For Each aTag In allATags
            	allPaths.Add(aTag.GetPath().ToString())
            Next
            
            ''' Creating the Adapters when they are needed
            Dim aTag1 As Ranorex.ATag = allPaths(0)
            aTag1.Click()
I hope this will help you solve the issue.

Regards,
Markus
Ranorex Support Team
.
Image

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Sometimes, 'click' action doesn't work

Post by Florian » Wed Sep 05, 2012 11:07 am

Thank you for your reply.

It seems to work. But it's slower than the previous code. Is it normal?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Sometimes, 'click' action doesn't work

Post by Support Team » Wed Sep 05, 2012 12:52 pm

Hi,

I am glad I was able to help :).
This is normal as Ranorex has to search for each used element twice.

Regards,
Markus
Ranorex Support Team
.
Image

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Sometimes, 'click' action doesn't work

Post by Florian » Wed Sep 05, 2012 2:07 pm

Finally, I got an error again :/

Here is the code:

Code: Select all

Dim allATags As IList(Of Ranorex.ATag) = repo.LDLClyon.Pieces.FindDescendants (Of Ranorex.ATag)
Dim allPaths As IList(Of String) = New List(Of String)
Dim aTag As Ranorex.ATag
		    
For Each aTag In allATags
	allPaths.Add(aTag.GetPath().ToString())
Next
		    
Randomize()
Dim iRandom as Integer = CInt(Int(allATags.Count * Rnd()))
Report.Log(ReportLevel.Info, "Mouse", "Choix de l'univers " & allATags(iRandom).InnerText, repo.LDLClyon.PiecesInfo)
		    
Dim aTag1 As Ranorex.ATag = allPaths(iRandom)
aTag1.Click()

Code: Select all

Module execution was aborted because a validation step has failed. Element '{ATag:Photo}' does not exist (element is not valid). 
Show/Hide Stacktrace
à Ranorex.Validate.IsTrueInternal(Boolean condition, String message, Options options, RepoItemInfo itemInfo) à Ranorex.Validate.Exists(Element element, String message, Options options) à LDLClyon.LDLClyon.NavigationProduit.ChoixUnivers() à LDLClyon.LDLClyon.NavigationProduit.Run() à Ranorex.Core.Testing.TestSuiteModule.RunInternal(DataContext parentDataContext)