# encoding:utf-8 from selenium import webdriver import time driver = webdriver.Firefox() driver.get("http://www.baidu.com") # 下面这一段使用的是python中变量的方法,简单吧! class Deleteproperty: def deleteproperty(self,rj,num=10,frequency=1): num=str(num) for i in range(frequency): time.sleep(1) rj.find_element_by_xpath("//*[@id="+ num +"]").click() return #下面这一段使用的好像是一种固定格式,在JS中有看到 def enter1(var1): driver.find_element_by_xpath("//input[@id = ‘" + var1 + "‘]").click() enter1(‘su‘) time.sleep(3) driver.quit() |
时间: 2024-10-06 16:43:45