1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
from selenium import webdriver import time
driver = webdriver.Chrome()
driver.get("http://[服务器ip]/yuns/index.php") time.sleep(3)
driver.maximize_window()
size = driver.find_element_by_xpath("//input[@class='but1']").size print(type(size)) print("搜索框的高是:", size['height']) print("搜索框的宽是:", size["width"])
text = driver.find_element_by_xpath("//div[@class='schhot']/a[2]").text print("获取控件上的文本信息:", text)
href = driver.find_element_by_xpath("//div[@class='schhot']/a[2]").get_attribute('href') print(href)
dis = driver.find_element_by_xpath("//div[@class='schhot']/a[2]").is_displayed() if dis == True: print("家装节按钮加载出来了!") driver.find_element_by_xpath("//div[@class='schhot']/a[2]").click() time.sleep(2) else: time.sleep(5) driver.find_element_by_xpath("//div[@class='schhot']/a[2]").click() time.sleep(2)
driver.find_element_by_xpath("//input[@class='but1']").clear() time.sleep(2)
driver.find_element_by_xpath("//input[@class='but1']").send_keys("test") time.sleep(2) value = driver.find_element_by_xpath("//input[@class='but1']").get_attribute("value") if value == "test": print("输入信息是test") else: print("输入信息不是test")
time.sleep(3) driver.quit()
|