Page 1 of 1

Retries After Initial Failure

Posted: Fri Apr 30, 2021 9:24 pm
by jmckinstry
In my test case, I am opening up a URL and it can either load correctly, or load a page with the title "Automation Error". I am looking at a <h3> tag to see if the Automation Error page is laded using the following in a code module:

Code: Select all

if(Validate.NotExists(repo.ApplicationUnderTest.Alert_Box_Components.Automation_Error_Page_HeadingInfo,null,true));
If the error page is loaded, the test will fail and go to the next iteration.

Everything works as expected except it does 28 retries which takes 7 seconds. How can I tell it to stop after say 2 tries? I would like it to just fail and go to the next iteration. Here is the message that I get in the report:

Element for item 'All_DNIS_TST_OutcomeRepository.ApplicationUnderTest.Alert_Box_Components.Automation_Error_Page_Heading' does not exist (Failed to find item 'All_DNIS_TST_OutcomeRepository.ApplicationUnderTest.Alert_Box_Components.Automation_Error_Page_Heading'. Please check that your whitelist allows Ranorex to access the process. No element found for path '/dom[@domain='agentwebtest' or @domain='agentwebdev']//div[#'content']//h1[@innertext='Automation Error']' at step 'descendant-or-self::h1[@innertext='Automation Error']' after 28 attempts within 7s (timeout factor = 0.2).).

Thanks for your help!

EDIT: I have the Retry count set to 0 on the testcase - if that helps.

Re: Retries After Initial Failure

Posted: Mon May 03, 2021 10:41 am
by odklizec
Hi,

To shorten the search timeout, you can use 'Duration' parameter. The code should look like this...

Code: Select all

if(Validate.NotExists(repo.ApplicationUnderTest.Alert_Box_Components.Automation_Error_Page_HeadingInfo.AbsolutePath,5000,null,true))
I would personally recommended to pass the repo element to code via method parameter, instead of hardcoding repo element directly in code:

Code: Select all

public void GetXpathFromRepoItemInfo(RepoItemInfo repoInfoElement)
{
    if(Validate.NotExists(repoInfoElement.AbsolutePath,5000,null,true))
    {
    ...
    }
} 

Re: Retries After Initial Failure

Posted: Mon May 03, 2021 2:24 pm
by jmckinstry
Thank you very much for your help. I believe that this is just what I am looking for. Especially putting it all into a method.

Jeff