There is a switch-on/switch-off element on a Web Page. And underneath, here is the source code defined:
<div class = "button">
<label class = "switch">
<input id="sim-switch" class = "hidden" type="checkbox">
<div class = "slider clearfix">
::before
<div class="on-text pull-left">ON</div>
<div class="off-text pull-left">OFF<div>
<div class="inner-slider"></div>
::after
</div>
</label>
</div>
And if was to put this step into selenium automation, I am not sure which part is the "click()" area to make this switch happen. Any ideas?
You can use checkbox for operation, first locate element and use the isChecked()
method with if else
conditions for operations:
WebElement ele= driver.findElement(By.id("sim-switch"));
if(ele.isSelected()==true)
{
System.out.println("it is clicked");
//append your operations
}
else
{
ele.click();
System.out.println("it is now clicked");
//append your operations
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments