Page 1 of 1

how to timeout on searching webdocument

Posted: Wed Oct 10, 2012 4:00 pm
by omayer
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

Re: how to timeout on searching webdocument

Posted: Thu Oct 11, 2012 8:51 am
by artur_gadomski
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;
}

Re: how to timeout on searching webdocument

Posted: Thu Oct 18, 2012 3:51 pm
by omayer
Thank you so much artur_gadomski for explained detail with code snippet, thank you again