Beispiel #1
0
driver.get("file:///C:/Users/11948/Desktop/checkbox.html")

check = Base(driver)

# loc1 = ("id","c1")
# r1 = check.isSelected(loc1)
# print(r1)
#
# che1 = check.click(loc1)
# r2 = check.isSelected(loc1)
# print(r2)

#复选框全部选中(复数定位)

loc_all = ("xpath", './/*[@type="checkbox"]')
all = check.findElements(loc_all)
print(all)  #list对象


def result(all):
    r = []  #判断全部被选中

    for i in all:
        if i.is_selected():
            pass
        else:
            i.click()
            r.append(i.is_selected())

        # if not i.is_selected():
        #     i.click()
Beispiel #2
0
loc1 = ("xpath", ".//*[@id='phone-form']/div[4]/div[2]/label[1]")
box1 = xinlang.isSelected(loc1)
print(box1)

#点击
che1 = xinlang.click(loc1)
#time.sleep(3)
loc2 = ("xpath", ".//*[@id='phone-form']/div[4]/div[2]/label[1]")
box2 = xinlang.isSelected(loc2)
print(box2)


#全部选中
loc_all = ("xpath", ".//*[@id='phone-form']/div[4]/div[2]")
all = xinlang.findElements(loc_all)

print(all)

def result():
    r = []#判断全部被选中

    for i in all:
        if not i.is_selected():
            i.click()
            r.append(i.is_selected)#判断结果
        else:
            r.append(i.is_selected)

    return r
rrrr =result(all)