zoukankan      html  css  js  c++  java
  • Selenium---Python3---弹框处理

    #!/usr/bin/env python
    
    from selenium import webdriver
    from selenium.webdriver.common.action_chains import ActionChains
    import time
    
    class driver_class(object):
        #建立一个Chrome对象
        def __init__(self):
            self.driver = webdriver.Chrome()
    
        def driver_dialog(self):
            self.driver.get('https://www.baidu.com/')
            #点击登陆链接
            login = self.driver.find_element_by_css_selector('.lb[name="tj_login"]')
            #点击登陆按钮
            ActionChains(self.driver).double_click(login).perform()
            #通过二次定位找到用户输入框
            div = self.driver.find_element_by_class_name("tang-content").find_element_by_name("userName")
            div.sendkeys("username")
            #输入登录密码
            self.driver.find_element_by_name("password").send_keys("password")
            #点击登录
            self.driver.find_element_by_id("TANGRAM__PSP_10__submit").click()
    
            time.time(10)
            self.driver.close()
    
    
    if __name__ == "__main__":
        a = driver_class()
        a.driver_dialog()
  • 相关阅读:
    20201016---不做清单
    20201014--增删改查
    20201013--什么是真实的自己?
    多态
    继承
    关键字
    分类思想
    常用的linux命令
    九九乘法表
    稀疏数组
  • 原文地址:https://www.cnblogs.com/aaron456-rgv/p/12716130.html
Copyright © 2011-2022 走看看