zoukankan      html  css  js  c++  java
  • selenium学习笔记06-CheckBox和radiobutton的定位技巧

    from selenium import webdriver
    from time import sleep
    import os
    class TestCase(object):
        def __init__(self):
            self.driver = webdriver.Chrome()
            path = os.path.dirname(os.path.abspath(__file__))
            file_path = 'file:///'+path +'/forms2.html'
            self.driver.get(file_path)
    
        def test_checkbox(self):
            swimming = self.driver.find_element_by_name('swimming')
            if not swimming.is_selected(): #被选中
                swimming.click()
            reading = self.driver.find_element_by_name('reading')
            if not reading.is_selected():
                reading.click()
            sleep(3)
            swimming.click()
            sleep(5)
            self.driver.quit()
    
        def test_radio(self): #radio具有排他性
            lst = self.driver.find_elements_by_name('gender')
            # lst[0].click()
            lst[1].click()
    
    
    if __name__ == '__main__':
        case = TestCase()
        # case.test_checkbox()
        case.test_radio()
  • 相关阅读:
    hdu 3367 Pseudoforest
    hdu 2489 Minimal Ratio Tree
    hdu 4009 Transfer water
    poj 3164 Command Network
    hdu 3926 Hand in Hand
    hdu 3938 Portal
    5-26日(面经总结)
    5-25日
    5-21日|5-22日
    5-13日记录|5-14日
  • 原文地址:https://www.cnblogs.com/yronl/p/14448028.html
Copyright © 2011-2022 走看看