美文网首页
selenium操作表单元素

selenium操作表单元素

作者: 徒手說梦话 | 来源:发表于2019-02-16 12:04 被阅读0次
    # 操作输入框
    '''
    from selenium import webdriver
    import time
    driver_path = r'D:\python\geckodriver-v0.23.0-win64\geckodriver.exe'
    driver = webdriver.Firefox(executable_path=driver_path)
    driver.get("https://www.baidu.com/")
    
    inputTag = driver.find_element_by_id('kw')
    inputTag.send_keys('python')
    time.sleep(2)
    inputTag.clear() # 清除输入框
    '''
    
    # 操作checkbox(记住当前选项/记住密码)
    from selenium import webdriver
    driver_path = r'D:\python\geckodriver-v0.23.0-win64\geckodriver.exe'
    driver = webdriver.Firefox(executable_path=driver_path)
    driver.get("https://accounts.douban.com/passport/login_popup?login_source=anony")
    
    remenberTag = driver.find_element_by_name("remember")
    remenberTag.click()
    
    # 操作select标签
    """ 
    from selenium import webdriver
    from selenium.webdriver.support.ui import Select
    
    driver_path = r'D:\python\geckodriver-v0.23.0-win64\geckodriver.exe'
    driver = webdriver.Firefox(executable_path=driver_path)
    driver.get("https://www.52pojie.cn/") 
    """
    

    相关文章

      网友评论

          本文标题:selenium操作表单元素

          本文链接:https://www.haomeiwen.com/subject/rhubeqtx.html