forked from Mohammad-Faiz/Selenium_Course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckbox.py
More file actions
21 lines (16 loc) · 657 Bytes
/
Checkbox.py
File metadata and controls
21 lines (16 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
#chrome driver without local chromedriver
service_obj = Service()
driver = webdriver.Chrome(service=service_obj)
driver.get("https://rahulshettyacademy.com/AutomationPractice/")
#store all the checkbox element in variable
checkboxes = driver.find_elements(By.XPATH, "//input[@type='checkbox']")
#itterate the desired option in checkbox and click that
for checkbox in checkboxes:
if checkbox.get_attribute("value") == "option1":
checkbox.click()
assert checkbox.is_selected()
break
driver.close()