pythonGUI自动化:selenium常用的操作

实现代码如下:

from selenium import webdriver
import time
#谷歌浏览器
wd=webdriver.Chrome()
#火狐浏览器
#wd=webdriver.Firefox()
#IE浏览器
#wd=webdriver.Ie()
#窗口最大化
wd.maximize_window()
#打开网站
wd.get("https://www.baidu.com")
time.sleep(2)
wd.find_element_by_id("kw").send_keys("周杰伦")
wd.find_element_by_xpath("//input[@id='su']").click()
time.sleep(5)
#刷新页面
# wd.refresh()
#截图
# wd.get_screenshot_as_file('1.png')
#关闭当前操作页面
# wd.close()
#关闭所有页面
# wd.quit()

猜你喜欢

转载自www.cnblogs.com/badbadboyyx/p/12152193.html