Forum Discussion

royd's avatar
royd
Regular Contributor
7 years ago
Solved

Switch statement troubles!

I have a situation where user login process involves EULA agreement. The user need to agree to the EULA to continue with the login process. This is configurable. So there are times when the EULA does...
  • tristaanogre's avatar
    7 years ago

    I don't think you need a switch statement for this at all.  It doesn't make sense to use a switch statement to make a decision between two boolean values. I'd write the code like this:

     

    var panelButtons = page.FindChildEx("Name", "Panel(3)", 10, true, 10000);  //thanks to Alex for suggesting ‘FindChildEx’                                                                      
    var btnAccept = panelButtons.FindChild("idStr", "ctl00_MainContent_btnAcceptEula", 10);
    
    page.Wait();
    if (btnAccept.Exists){     
            Log.Message("EULA page loaded."); 
            btnAccept.scrollIntoView(false);                                            
            btnAccept.ClickButton();   
        }
        else {
           Log.Message("EULA page did not load."); 
        }