Validate element exist or not exist

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 11
Joined: Thu Aug 21, 2014 7:50 pm

Validate element exist or not exist

Post by rawatankit6 » Fri Aug 22, 2014 7:25 pm

Hi Ranorex,

I have a query here In my application when i select say "Advanced Fields" button an "Advanced search" textbox comes up, I have to validate the particular text box exist only when the user click "Advanced Fields" button and vice versa. The advanced search text box is uniquely identified by @id attribute, so if I use only the @id attribute and try to track the object when the "Advanced Fields" button is not clicked I get one result and same result i got when the object is visible to me(when i click the advanced field button), so i added @visible attribute along with the @id attribute to identify the object only when the user clicks the "Advanced Fields" button. So i have x path something like this input[@id="Advanced Search" and @visible ='True'] but I am not sure how to validate the particular element "Advanced Search" doesn't exist when "Advanced Fields" button is not clicked. How can I solve this issue and expect ranorex not to wait for default 2m for the element to not exist?

Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Validate element exist or not exist

Post by krstcs » Fri Aug 22, 2014 8:08 pm

Anytime you validate that something does NOT exist, Ranorex will wait for the full search timeout of the object and all parent objects. This is by design and cannot be changed.

One way to get around this is to create a second version of the repository object that points at the same item and set that copy's timeout to something very short, but long enough to allow Ranorex to validate it (say 10s). You could then put that copy in the root of the application so you only have the application's root timeout and that object's timeout to worry about.

For example, let's say you have a repo object like this:

Code: Select all

MyDomain -> /dom[@domain='']  (timeout of 30s)
  MyDiv -> /body/div[@id='mydiv'] (timeout 30s)
    MyButton -> /button[@id='mybutton' and @visible='True'] (timeout of 30s, this is the one you want to use for most actions)
You would then copy the button object and name it "MyButton_ShortTimeout". Move it to where it is a direct child of the /dom object, and then set the timeout to 10s. You would use THIS object when you need to validate not exists. Instead of the 90s total timeout, it would be 40s, total. The path would look like this:

Code: Select all

MyDomain -> /dom[@domain='']  (timeout of 30s)
  MyButton_ShortTimeout -> /body/div[@id='mydiv']/button[@id='mybutton' and @visible='True'] (timeout of 10s, use for NOT exists)
  MyDiv -> /body/div[@id='mydiv'] (timeout 30s)
    MyButton -> /button[@id='mybutton' and @visible='True'] (timeout of 30s)
The absolute path is still the same, but the new object has a shorter absolute search timeout.

You could then Validate NotExist on this shorter object.
Shortcuts usually aren't...