Page 1 of 1

Validate with Ifs for combobox

Posted: Fri Jun 15, 2012 12:23 pm
by j.early
Hello all,

new user to ranorex and have a question.

I have a File > open dialog box which changes it default opening location depented on the last location used to open a file.

For example,

I select open > File and its in the default install folder.
browse to C:/Test/images and open an image.
Close the app
Reopen and the default location has changeged from install folder to "C:/Test/images "

I want to be able to check the drop down box of the File open dialog value and if its not the default install folder then browse to that folder.

Any help would be great
Cheers

Re: Validate with Ifs for combobox

Posted: Fri Jun 15, 2012 4:04 pm
by Ciege
First option is to read the text of the dialog at runtime. If it is not what you want, then perform the action to change the location.

Second option is to always perform the option to change the location. It's not like it is a large time consumer to change the option, and you have to write the change location method regardless of the first or second option.

Re: Validate with Ifs for combobox

Posted: Mon Jun 18, 2012 12:45 pm
by j.early
I have the option to change the location done and all, its just making it work based on an If.

For example, I have one recorded script that does the change, named FileOpenDemoImageLocation

So when the script checks the drop down box for "images" text it should continue the test as nomarl.

If "images" is not in the drop down, it must run FileOpenDemoImageLocation to move to this location.


if "combobox" text ois not images

then run FileOpenDemoImageLocation

else

continue test

Been trying many ways but my syntax isn't up to scratch yet :(

Thanks
J

Re: Validate with Ifs for combobox

Posted: Mon Jun 18, 2012 4:03 pm
by Ciege
Here is some c# pseudo code... Since I don't know your elements, XPaths etc I can't write specific code for you...

Code: Select all

//First read the test in the combobox and set to a variable
ranorex.combobox MyCombo = XPath to the combobox;
string MyPath = Mycombo.text;

//Now do the test
if (MyPath != "C:/Test/images")
{
  //Do your work here to set the combobox path
  FileOpenDemoImageLocation ();
}

Re: Validate with Ifs for combobox

Posted: Wed Jun 20, 2012 10:17 am
by j.early
thanks Ciege, your a gent, was able to get it working now.

Thanks
J