Python. How to handle CheckBox verification
Check-box verification in simple way.
[code language="python"]
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
driver.get("http://blah_blah.com")
try:
elem= driver.find_element(By.NAME, "chk_email")
if (elem.is_selected()):
print("Checkbox is selected...now deselecting")
elem.click()
else:
print("Checkbox is not selected..now selecting")
elem.click()
driver.close()
except Exception as e:
print ("Exception occurred", format(e));
finally:
driver.quit()
print ("done")
[/code]
[code language="python"]
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
driver.get("http://blah_blah.com")
try:
elem= driver.find_element(By.NAME, "chk_email")
if (elem.is_selected()):
print("Checkbox is selected...now deselecting")
elem.click()
else:
print("Checkbox is not selected..now selecting")
elem.click()
driver.close()
except Exception as e:
print ("Exception occurred", format(e));
finally:
driver.quit()
print ("done")
[/code]
Comments
Post a Comment