Reputation: 765
this is my original screenshot.
And this is the screenshot after I have click the on-off area on it.
This is the original html for the on-off area:
<div region="child-0" class="togglebar-item inline-block region region-child-0">
<div data-view-name="anonymous-view-11401" data-render-count="2">
<div class="ftnt-on-off-switch-ct">
<div class="ftnt-on-off-switch inline-block">
<input type="checkbox" id="ftnt-on-off-input--toggle-0" class="" action="action" data-mkey="1325" data-id="toggle-0">
<label for="ftnt-on-off-input--toggle-0"></label>
<div class="slider"></div>
</div>
</div>
</div>
</div>
And this is the html after the on-off area has been clicked.
<div region="child-0" class="togglebar-item inline-block region region-child-0">
<div data-view-name="anonymous-view-11492" data-render-count="2">
<div class="ftnt-on-off-switch-ct">
<div class="ftnt-on-off-switch inline-block">
<input type="checkbox" id="ftnt-on-off-input--toggle-0" class="" action="action" checked="" data-mkey="1325" data-id="toggle-0">
<label for="ftnt-on-off-input--toggle-0"></label>
<div class="slider"></div>
</div>
</div>
</div>
</div>
My question is: In selenium python, after I click the on/off area, how may I detect the on/off happens ???
I need to add a test case for this, as sometimes even People have click the on-off, it never happens.
Upvotes: 0
Views: 45
Reputation: 57
Alternately you may use something like this as well . I have tried this approach in java and you can definitely use it in python as well.
String color = element.getCssValue("color");
You can get the color from the style tab in the inspector and check if the color has changed
Upvotes: 1
Reputation: 4177
# if its checked checkboxes
wait.until(EC.presence_of_element_located((By.cssSelector, "input:checked[type='checkbox']")))
# if its not checked checkboxes
wait.until(EC.presence_of_element_located((By.cssSelector, "input:not(:checked)[type='checkbox']")))
Upvotes: 0