标签:class https pass action send sub 按钮 selector click
#!/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()
标签:class https pass action send sub 按钮 selector click
原文地址:https://www.cnblogs.com/aaron456-rgv/p/12716130.html