Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to wait for/detect 302 in Selenium and continue to the next item?

I have this Selenium pseudo-code:

// initializing ChromeDriver here, also I use Titanium Web Proxy
var pages = GetPagesToBeAnalyzed();
foreach(var page in pages)
{
    driver.Url = page.Url;
    // here, some pages result in 302. 
    // I want following lines of codes to be executed,
    // only if the HTTP result is 200,
    // otherwise, I want to continue to the next page
    DoSomethingWithPagesThatReturn200();
}

I'm stuck on how to detect 302, or wait for it, to continue to the next page. I can make implicit waits for certain elements and encounter error and go to the next page, but that's not efficient. I want to move to the next item as soon as I got 302 for any page.

Comments