Object not found when exe called from other code.
Posted: Wed Jul 01, 2015 9:15 pm
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:
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:
LMK if any other information from my project is required. Thanks in advance for your help.
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:
Here is the result of some experiments: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)
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.
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");
...
}