[python] view plain copy
- <span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size:18px;">
[python] view plain copy
- <span style="font-size:18px;">from selenium import webdriver
- import time
- driver=webdriver.Ie()
- driver.get("http://m.mail.10086.cn")
- driver.implicitly_wait(30)
- driver.find_element_by_id("ur").send_keys("15610537527")
- driver.find_element_by_id("pw").send_keys("15866584957")
- data1 = driver.find_element_by_class_name("loading_btn").text
- print "该元素文本为:"
- print data1
- data2 = driver.find_element_by_class_name("loading_btn").get_attribute("id")
- print "该元素id属性值为:"
- print data2
- driver.find_element_by_class_name("loading_btn").click()
- time.sleep(5)
- print driver.title
- print ":页面访问成功!"
[python] view plain copy
- now_url = driver.current_url
- print now_url
- print "浏览器最大化:"
- driver.maximize_window()
- print "设置浏览器宽480、高800显示:"
- driver.set_window_size(480, 800)
- print "后退到上一个网页:"
- driver.back()
- time.sleep(1)
- print "前进到下一个网页:"
- driver.forward()
- time.sleep(2)
- driver.close()