code of Handling unexpected Dialogs in vb.net is not working

Ranorex Spy, Recorder, and Studio.
yoad
Posts: 39
Joined: Sun May 26, 2013 9:08 am

code of Handling unexpected Dialogs in vb.net is not working

Post by yoad » Wed Jun 26, 2013 1:28 pm

hello,I create new file--->UserCodeModule.vb---> I put code of Handling unexpected Dialogs
but I don't see that code is not closing my windows in project why?
' Time: 11:55
'
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Drawing
Imports System.Threading
Imports WinForms = System.Windows.Forms

Imports Ranorex
Imports Ranorex.Core
Imports Ranorex.Core.Testing

Namespace Easyadmin
   ''' <summary>
   ''' Description of UserCodeModule1.
   ''' </summary>
   <TestModule("705D7E00-647A-492F-A5E7-D62E35725C42", ModuleType.UserCode, 1)> _
   Public Class UserCodeModule1
        Implements ITestModule
         
         private repo As EasyadminRepository=EasyadminRepository.Instance
        ''' <summary>
        ''' Constructs a new instance.
        ''' </summary>
        Public Sub New()
            ' Do not delete - a parameterless constructor is required!
        End Sub

        ''' <summary>
        ''' Performs the playback of actions in this module.
        ''' </summary>
        ''' <remarks>You should not call this method directly, instead pass the module
        ''' instance to the <see cref="TestModuleRunner.Run(Of ITestModule)"/> method
        ''' that will in turn invoke this method.</remarks>
        Private Sub Run() Implements ITestModule.Run
            Mouse.DefaultMoveTime = 300
            Keyboard.DefaultKeyPressTime = 100
            Delay.SpeedFactor = 1.0
'      dom[@domain='localhost:7019']//div[@Id~'^*-window']
'        Dim webDocument As WebDocument ="/dom[@domain='localhost:7019']"
''       Dim Div As DivTag = webDocument.FindSingle(".//div[@Id~'^*-window']")
'        Dim div1 As ATag=webDocument.FindSingle(".//div[#'gridview-[0-9][0-9][0-9][0-9]']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[6]/div/a[@innertext='23']")
'        div1.Click()
   '   Dim repo As GlobalRepository = GlobalRepository.Instance
            ' Create PopupWatcher   
    Dim myPopupWatcher As New PopupWatcher()   
  
    ' Add a Watch using a RanoreXPath and triggering the Method CloseUpdateCheckDialog   
    myPopupWatcher.Watch("/form[@controlname='UpdateCheckForm']/button[@controlname='m_btnClose']", AddressOf CloseUpdateCheckDialog)   
  
    ' Add a Watch using the info object of a button and triggering the Method CloseUpdateCheckDialog   
    ' myPopupWatcher.Watch(repo.UpdateCheckDialog.btCloseInfo, CloseUpdateCheckDialog);   
  
    ' Add a Watch using the info object of the dialog and the info object of the button to click   
    ' myPopupWatcher.WatchAndClick(repo.UpdateCheckDialog.SelfInfo, repo.UpdateCheckDialog.btCloseInfo);   
  
    ' Add a Watch using a repository folder object and the info object of the button to click   
    ' myPopupWatcher.WatchAndClick(repo.UpdateCheckDialog, repo.UpdateCheckDialog.btCloseInfo);   
  
    ' Start PopupWatcher   
    myPopupWatcher.Start()   
  
End Sub  
  
Public Shared Sub CloseUpdateCheckDialog(myInfo As Ranorex.Core.Repository.RepoItemInfo, myElement As Ranorex.Core.Element)   
    myElement.[As](Of Ranorex.Button)().Click()   
End Sub  
  
Public Shared Sub CloseUpdateCheckDialog(myPath As Ranorex.Core.RxPath, myElement As Ranorex.Core.Element)   
    myElement.[As](Of Ranorex.Button)().Click()  
        
  

       
       End Sub
    End Class
End Namespace

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

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by Support Team » Thu Jun 27, 2013 3:30 pm

Hello,

You might need to adjust the RxPath to match the path of your dialog:

Code: Select all

/form[@controlname='UpdateCheckForm']/button[@controlname='m_btnClose']
Please open Spy and verify the path that is used to identify your dialog.

Regards,
Markus (T)
.
Image

yoad
Posts: 39
Joined: Sun May 26, 2013 9:08 am

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by yoad » Sun Jun 30, 2013 8:38 am

if my form is chorme of google or "/dom[@domain='localhost:7019']/"
how do I find out controlnames of my form?
please see picture
Attachments
1.jpg
1.jpg (153.28 KiB) Viewed 1443 times

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

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by Support Team » Mon Jul 01, 2013 3:14 pm

Hello,

It's not necessary to have a control name of your dialog. You would only need to find out the RanoreXPath of your form that uniquely identifies it. I would recommend to take a look at our User Guide for detailed information on how to get a RanoreXPath of a specific element.

Could you please post a 'Ranorex Snapshot' of your application (showing the dialog) in order to analyze this issue? Please take a look at Creating Ranorex Snapshot Files in our User Guide.

Thank you.

Regards,
Markus (T)
.
Image

yoad
Posts: 39
Joined: Sun May 26, 2013 9:08 am

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by yoad » Thu Jul 04, 2013 8:35 am

hello,I added snapshot file of window
thank you
Attachments
onewindow.rxsnp
(351.96 KiB) Downloaded 164 times

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

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by Support Team » Thu Jul 04, 2013 3:12 pm

Hello,

Thank you for your snapshot.
You could try to use the following RxPath for the popup watcher:

Code: Select all

/dom[@domain='localhost:7019']//div[#'tool-1212']
Please note that you would need to use the DivTag instead of a Button in your case.

Regards,
Markus (T)
.
Image

yoad
Posts: 39
Joined: Sun May 26, 2013 9:08 am

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by yoad » Sun Jul 07, 2013 7:50 am

Hello Markus,

I tried with them
/dom[@domain='localhost:7019']//div[#'tool-1112']
or
/dom[@domain='localhost:7019']//div[@id~'tool-\d\d\d\d]
or
/dom[@domain='localhost:7019']//img[@id~'tool-\d\d\d\d-toolEl']
or
/dom[@domain='localhost:7019']//div[#'tool-1112']//img[#'tool-1112-toolEl']

but they are not working

why?

Kind regards,

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

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by Support Team » Mon Jul 08, 2013 1:32 pm

Hello,

Have you already tried the following path?

Code: Select all

/dom[@domain='localhost:7019']//div[#'tool-1212']
It looks like that these paths are not correct.
Have you already tried these paths in Spy?
Is it possible to highlight your elements?

Regards,
Markus (T)
.
Image

yoad
Posts: 39
Joined: Sun May 26, 2013 9:08 am

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by yoad » Tue Jul 09, 2013 5:16 am

these paths are correct
yes i tried these in spy
and it is possible to highlight my elements

if you have idea?

thank you
Regards,
Yoad

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

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by Support Team » Wed Jul 10, 2013 10:04 am

Hello,

I couldn't find any div tag with the ID 'tool-1112' in your snapshot.
Could you please verify if the ID of your div tags change every test run?
If yes, your application uses dynamic IDs.
We provide a blog that describes how to handle with dynamic IDs.

Have you tried to debug your project in order to find out if the method is called correctly?

Thank you in advance.

Regards,
Markus (T)
.
Image

yoad
Posts: 39
Joined: Sun May 26, 2013 9:08 am

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by yoad » Wed Aug 07, 2013 3:36 pm

in debug it is working with myPopupWatcher.Start() and
it is finishing program


kind regards,
Yoad
Attachments
CloseWindow.rxsnp
(407.07 KiB) Downloaded 155 times

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

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by Support Team » Fri Aug 09, 2013 9:56 am

Hello,

I am not sure what you mean.
Could you please clarify your issue?

Regards,
Markus (T)
.
Image

yoad
Posts: 39
Joined: Sun May 26, 2013 9:08 am

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by yoad » Mon Sep 02, 2013 8:46 am

Hello,
I did it with debug but it does not happen nothing
Automation does not close divs of windows or solve dialogs

regards,
Yoad

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

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by Support Team » Tue Sep 03, 2013 7:52 am

My guess is that the PopupWatcher is cleaned up just after being started, because it is assigned to a local variable. Try declaring the PopupWatcher as a shared member variable of the module, outside of the Run method:
yoad wrote:Shared myPopupWatcher As New PopupWatcher()
Regards,
Alex
Ranorex Team
.
Image

yoad
Posts: 39
Joined: Sun May 26, 2013 9:08 am

Re: code of Handling unexpected Dialogs in vb.net is not working

Post by yoad » Tue Sep 03, 2013 10:16 am

Hello,
thanks about help

I tried declaring but it does not happening nothing
I also tried declaring again with " Dim myPopupWatcher As New PopupWatcher() " out of run method
but it does not happening something

I tried change method to public:

Code: Select all

Public Sub CloseUpdateCheckDialog(myInfo As Ranorex.Core.Repository.RepoItemInfo, myElement As Ranorex.Core.Element)   
    myElement.[As](Of Ranorex.Button)().Click()   
End Sub  
  
Public Sub CloseUpdateCheckDialog(myPath As Ranorex.Core.RxPath, myElement As Ranorex.Core.Element)   
    myElement.[As](Of Ranorex.Button)().Click()  
but it does not happening something

if you have idea?

regards,
Yoad