Page 1 of 1

Object not found when exe called from other code.

Posted: Wed Jul 01, 2015 9:15 pm
by kewpiedoll99
I have a short automated Ranorex test that goes to a Chrome window and changes the widths of some table columns, clicks an icon, fills in a form, and so on. My process is to do most of the setup using Java code, and then call this exe to execute a portion of the test. The Java code opens the Chrome browser and carries out various actions before calling the exe.

I have copied the Ranorex .exe and .rxtst files from the bin/Debug directory into a directory inside the Java directory structure (for access by the Java code). It's not feasible for me to change to the bin/Debug directory before calling the exe, so I am confused about how to get this to work.

When I test the exe by itself from the command line, it executes fine. When I call it from the Java app, it returns a nonzero value indicating failure:
Object reference not set to an instance of an object.
at CloneInstHtmlPage.Recording1.WidenPublishCloneColumn() at CloneInstHtmlPage.Recording1.Ranorex.Core.Testing.ITestModule.Run() at Ranorex.Core.Testing.TestSuiteModule.RunInternal(DataContext parentDataContext)
Here is the result of some experiments:

Code: Select all

When I execute from the command line and a Chrome browser window is open, 
    if I run the exe from the {projectname}/bin/Debug directory, 
        the exe executes its commands in the existing Chrome browser window.

    else if I run the exe from another dir by providing the full path to the exe,
        the exe generates the error above.

    else if I run a copy of the exe (copied from the Debug dir to another dir),
        the exe generates the error above.
I'm frankly not clear on how the exe "knows" to look in Chrome, since I do not open up a Chrome browser as part of the Ranorex test. If a Chrome window is not already open, no matter how/from which dir I run the exe, it generates the error above.

In case it is relevant, here is the method in question:

Code: Select all

private void WidenPublishCloneColumn() {
     // change width of header cells
     string hdrTdRxPathBase = "/dom/body/div[@id='main-3343801']/div/div[2]/div/div[2]" +
         "/div/div/div/div[2]/div/div/div[3]/div/div/div/div[2]/div/div[2]/div/div/div[3]" +
         "/div/div/div/div/div[1]/div[1]/div[1]/table/tbody/tr/td";
                        
     TdTag hdrTd = null;
     string hdrTdRxPath = hdrTdRxPathBase + "[" + 9 + "]";

     Host.Local.TryFindSingle(hdrTdRxPath, 1000, out hdrTd);
     hdrTd.SetStyle("width","10px");
     DivTag innerHdrDiv = null;
     Host.Local.TryFindSingle(hdrTdRxPath + "/div[3]", 1000, out innerHdrDiv);
     innerHdrDiv.SetStyle("width","10px");
     ...
}
LMK if any other information from my project is required. Thanks in advance for your help.

Re: Object not found when exe called from other code.

Posted: Fri Jul 03, 2015 2:00 pm
by Support Team
Hi kewpiedoll99,

In order to analyze this issue in more detail I'd need additional information.
Therefore, may I ask you to answer the following questions?
  • Which version of Ranorex are you using?
  • Which Operating System is installed on your system?
  • Is your java application started as Administrator?
  • Is it possible for your to provide a short sample whereby this problem occurs?
This should help us analyzing and reproducing the issue on our side. Thank you in advance.

PS: If you don't want to post the application and the information in this public forum, you can also send an email to [email protected]

regards,
Markus (S)

Re: Object not found when exe called from other code.

Posted: Tue Jul 14, 2015 9:31 pm
by kewpiedoll99
I sent a reply to the email address, including a zip of my project. Thank you!