lundi 2 septembre 2019

how to state a If to verify if a class has a specific attributte?

I gotta verify if a button is "selected", if it is, then we can procede the test, if not, select it.

I tried the bellow code. What is the proper way to set up this?

External HTML: I need to verify the ng-scope: selected, if this div is selected then continue, if not continue.

<div class="list-toggle uppercase management_item newFeature selected" ng-class="{ 'selected': viewModel.selectedActionGroup == 'DistributionGroup', 'newFeature': i.isNew, 'standardFeature': !i.isNew}">

Code:

 var element = driver.FindElement(By.CssSelector(".col-md-3 > div:nth-child(1) > div:nth-child(3) > a:nth-child(1) > div:nth-child(1) > span:nth-child(2)"));

            if (element.GetAttribute("class").Contains("selected"))
            {
                return;
            }
            else
            {
                element.Click();
            }


The issue is that i made the verification but the program clicks on it either way.

Aucun commentaire:

Enregistrer un commentaire