Having one of those days, booleans

Man of Honour
Joined
29 Jun 2004
Posts
21,615
Location
Oxfordshire
Morning!

So this should be easy, but for some reason my brain isn't functioning at the moment

Code:
public static bool CheckOCRLanguagePageLoadCorrectly(IWebDriver driver)
        {
            Selenium.ClickLinkByText(driver, "OCR Language");

            bool success = PageObjects.CheckOldPageActiomBarLoadsCorrectly(driver);

            success = PageObjects.CheckSearchOptionsLoadsCorrectly(driver);

            success = PageObjects.CheckDataGridLoadsCorrectly(driver);

            return success;
        }

The problem I'm having is, say the top one returns false, but the other two return true, the false value will be lost and the function that uses this return value will see it as true, when really it should be a failure. Sometimes there could be up to 12 of these calls, so don't really want 12 seperate bool variables, so is there a way of doing this using the same variable, but will drop out the function if one returns true, failing that, will run through the entire function but return false if any of the statements at any point returned false?

Thanks guys, apologies if I explained that badly, like I said, just one of those days that my brain isn't firing! :D
 
Last edited:
Man of Honour
OP
Joined
29 Jun 2004
Posts
21,615
Location
Oxfordshire
Thank you very much kind sir!

I never knew about that either. What's that wizadry called out of curiosity?

EDIT - Boolean logical operators, I now feel slightly dumb that I did not know these existed!
 
Last edited:
Man of Honour
OP
Joined
29 Jun 2004
Posts
21,615
Location
Oxfordshire
That would work as well!

I think I'll stick with the first option only because it means I'm still able to run all of the methods if I need too! But on some where I want it to quit out asap then yours is the better one for me!

Thanks guys
 
Back
Top Bottom