how to timeout on searching webdocument

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

how to timeout on searching webdocument

Post by omayer » Wed Oct 10, 2012 4:00 pm

How do I make dynamic timeout in below line of code - if its not found witin 30sc then exit
WebDocument webdoc = "/dom[@browser='ww.ya.com']";
Thank you in advance
Tipu

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: how to timeout on searching webdocument

Post by artur_gadomski » Thu Oct 11, 2012 8:51 am

This is a piece of code that we deemed worthy of entering into our Ranorex best Practices document. Screnshot is there to visually verify failure, Snapshot to analyze paths in case it's the path is wrong. Failure instead of Error as errors are not seen on top level in Ranorex report. we use timeSpan as it's easy to see how long it takes (once you know it's hours, minutes, seconds).
WebDocument webdoc;
bool found = Host.Local.TryFindSingle("/dom[@browser='www.ya.com']", new TimeSpan(0,0,30), out webdoc);
if (!found) {
    Report.Failure("Webdoc not found.");
    Report.Screenshot();
    Report.Sanpshot(Host.Local);
    return;
}

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: how to timeout on searching webdocument

Post by omayer » Thu Oct 18, 2012 3:51 pm

Thank you so much artur_gadomski for explained detail with code snippet, thank you again
Tipu