I have a recording "hello.rxrec" that I'm trying to run from VB code in another record.
From what I read, I only need to use "hello.Start()". However, I get an error "test is not declared. It may be inaccessible due to its protection level."
This seems like it should be pretty simple, not sure what I'm doing wrong.
Start recording from user code
Re: Start recording from user code
First, why are you trying to start a module from another module? Modules are designed to be run in test cases from the suite.
In this case though, you would need to declare a variable for the test module and instantiate it, then call the Start() method on the variable like this:
Test modules are just .NET classes. They conform to specific interfaces that Ranorex has designed, but they still need to be instantiated before you can work with them.
Second, when raising issues please include the following information:
Ranorex version
Windows version
System under test (SUT) technology (if applicable)
Any error messages (if applicable)
The code you are using (if applicable)
In this case though, you would need to declare a variable for the test module and instantiate it, then call the Start() method on the variable like this:
Code: Select all
Hello helloModule = new Hello(); //instantiate the variable (helloModule) as a type of Hello
helloModule.Start(); //call Start() on the variable
Second, when raising issues please include the following information:
Ranorex version
Windows version
System under test (SUT) technology (if applicable)
Any error messages (if applicable)
The code you are using (if applicable)
Shortcuts usually aren't...
Re: Start recording from user code
Thanks for the reply.
I'm testing logging into a web app. If the user is already logged in, all my tests fail, so I need to run a specific recording to log out if I detect that the web app is already logged in.
I didn't include the version information because my issue wasn't really version specific.
I'm testing logging into a web app. If the user is already logged in, all my tests fail, so I need to run a specific recording to log out if I detect that the web app is already logged in.
I didn't include the version information because my issue wasn't really version specific.
Re: Start recording from user code
Please read the following post from the Ranorex team about what information to include when raising issues on the forums: http://www.ranorex.com/forum/please-rea ... -t871.html. This information helps everyone stay on the same page when talking about what is going on.
As for your situation, you should consider creating the logout module so that it can tell if it needs to logout or not and then just include it in all tests. You can create the logout module so that it handles either path with user code. This will keep you from needing to start modules from other modules.
Basically it would look like this in your user-code:
As for your situation, you should consider creating the logout module so that it can tell if it needs to logout or not and then just include it in all tests. You can create the logout module so that it handles either path with user code. This will keep you from needing to start modules from other modules.
Basically it would look like this in your user-code:
Code: Select all
if (loggedIn) {
Report.Info("USER", "Logged in. Logging user out.");
DoLogoutStuff();
} else {
Report.Info("USER", "Not logged in.");
}
Shortcuts usually aren't...