Validate with Ifs for combobox

Class library usage, coding and language questions.
j.early
Posts: 32
Joined: Fri Jun 15, 2012 12:14 pm

Validate with Ifs for combobox

Post by j.early » Fri Jun 15, 2012 12:23 pm

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

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Validate with Ifs for combobox

Post by Ciege » Fri Jun 15, 2012 4:04 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

j.early
Posts: 32
Joined: Fri Jun 15, 2012 12:14 pm

Re: Validate with Ifs for combobox

Post by j.early » Mon Jun 18, 2012 12:45 pm

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

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Validate with Ifs for combobox

Post by Ciege » Mon Jun 18, 2012 4:03 pm

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 ();
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

j.early
Posts: 32
Joined: Fri Jun 15, 2012 12:14 pm

Re: Validate with Ifs for combobox

Post by j.early » Wed Jun 20, 2012 10:17 am

thanks Ciege, your a gent, was able to get it working now.

Thanks
J