c# - WatiN - Waiting for Cookies -


i have been assigned create 'kind of' web creeper. tasks go on websites, enter piece of data submit data receive result.

i have found watin great tool @ getting data it's open source , has functionality need - if misuse of testing api (is misuse?).

anyway - real question is,

browser.waitforcomplete();

does not wait load. seems waits last body tag returns. believe cookie not generated when page finished loading it's being generated asp.net end - seems load after interactive object looks ajax or along them lines.

i not own or host web site therefore can gather information based on see browser , other tools @ disposal.

is there way watin wait cookie updated?

thanks in advanced.

john.

edit:

as example of i'm doing fix issue @ minute (which bit unorthodox it's fixing minute).

browser.waitforcomplete();
browser.waitforcomplete();
browser.waitforcomplete();
browser.waitforcomplete();
browser.waitforcomplete();
browser.waitforcomplete();
browser.waitforcomplete();
browser.waitforcomplete();

var cookie = browser.eval("document.cookie");

now may understand why want find real solution.

thanks

i'm not sure capture event this, suspect there must javascript running on page updates cookie.

if can tell difference between "old" , "updated" cookie, try this:

// maximum number of loops, avoid infinite loops int maxloops = 10;  // wait page complete browser.waitforcomplete();  // grab copy of current cookie var cookie = browser.eval("document.cookie");  // hack: dirty hack wait cookie updated while (cookieisnotupdated(cookie) && i++ <= maxloops) {     browser.waitforcomplete(); // (or other wait/sleep)     cookie = browser.eval("document.cookie"); } 

this isn't nice way of doing it, should work in absence of better.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -