-
Notifications
You must be signed in to change notification settings - Fork 0
/
selenium_03_button_check.py
41 lines (32 loc) · 1.07 KB
/
selenium_03_button_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 2019.10.21
# Checkbox 처리
from selenium import webdriver
from array import *
import time, unittest
class CheckBoxTest (unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
def test_checkbox(self):
driver = self.driver
driver.get("I:\Selenium\prac\web1.html")
car = driver.find_element_by_xpath("/html/body/form/input[2]")
# 체크가 되어있지 않다면 체크
if car.is_selected() == False:
car.click()
self.assertEqual(True,car.is_selected())
# 체크 해제
if car.is_selected():
car.click()
self.assertEqual(False,car.is_selected())
print("check_test success!!!")
# Element 검색 후 체크
gender_type = driver.find_elements_by_name("gender")
for type in gender_type:
if type.get_attribute("value") == "male":
type.click()
print("find_elements success!!!")
time.sleep(5)
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()