lundi 10 mai 2021

Why I can't toggle the switch button in Java?

I have a switch to toggle in order to activate/ deactivate an account. In source code it looks like this:

<input type="checkbox" name="acc-status" class="status-btn-checkbox" id="active-status">

I need a code that will check if the account is active and will toggle the switch to 'active' if it's inactive. I wrote something like this but it doesn't work:

//Check if Account is ACTIVE and activate if it's not
            
        String accactive = null;
        

        WebElement XActive = driver.findElement(By.id("active-status"));
        Boolean ActiveSwitch = XActive.isSelected();
        
        if(ActiveSwitch != true)
        {
            driver.findElement(By.id("active-status")).click();
        }



Aucun commentaire:

Enregistrer un commentaire