zoukankan      html  css  js  c++  java
  • selennuim,

    from selenium import webdriver
    
    import time
    bro=webdriver.Chrome()
    bro.get("http://www.baidu.com")
    bro.implicitly_wait(10)
    # 1、find_element_by_id   根据id找
    # 2、find_element_by_link_text     根据链接名字找到控件(a标签的文字)
    # 3、find_element_by_partial_link_text   根据链接名字找到控件(a标签的文字)模糊查询
    # 4、find_element_by_tag_name       根据标签名
    # 5、find_element_by_class_name     根据类名
    # 6、find_element_by_name           根据属性名
    # 7、find_element_by_css_selector   根据css选择器
    # 8、find_element_by_xpath          根据xpath选择
    
    dl_button=bro.find_element_by_link_text("登录")
    dl_button.click()
    user_login=bro.find_element_by_id('TANGRAM__PSP_10__footerULoginBtn')
    user_login.click()
    time.sleep(1)
    input_name=bro.find_element_by_name('userName')
    input_name.send_keys("30323545@qq.com")
    input_password=bro.find_element_by_id("TANGRAM__PSP_10__password")
    input_password.send_keys("xxxxxx")
    submit_button=bro.find_element_by_id('TANGRAM__PSP_10__submit')
    time.sleep(1)
    submit_button.click()
    
    time.sleep(100)
    
    print(bro.get_cookies())
    bro.close()
    
    #显示等待和隐示等待
    #隐式等待:在查找所有元素时,如果尚未被加载,则等10秒
    # browser.implicitly_wait(10)   表示等待所有,
    
    #显式等待:显式地等待某个元素被加载
    # wait=WebDriverWait(browser,10)
    # wait.until(EC.presence_of_element_located((By.ID,'content_left')))
  • 相关阅读:
    笔记44 Hibernate快速入门(一)
    tomcat 启用https协议
    笔记43 Spring Security简介
    笔记43 Spring Web Flow——订购披萨应用详解
    笔记42 Spring Web Flow——Demo(2)
    笔记41 Spring Web Flow——Demo
    Perfect Squares
    Factorial Trailing Zeroes
    Excel Sheet Column Title
    Excel Sheet Column Number
  • 原文地址:https://www.cnblogs.com/yangxinpython/p/11945609.html
Copyright © 2011-2022 走看看