先安装好环境,测试第一个简单程序:
# -*- coding: utf8 -*-
from selenium import webdriver
#使用Chrome
#ChromeDriverServer="E:\MySoftGit\Python\Selenium\chromedriver.exe"
#driver= webdriver.Chrome(ChromeDriverServer)
#使用Firefox
FireFoxDriverServer="E:\MySoftGit\Python\Selenium\geckodriver.exe"
driver= webdriver.Firefox(executable_path=FireFoxDriverServer) #Firefoxy 要指定executable_path参数
driver.get('https://www.baidu.com')
driver.find_element_by_id("kw").send_keys('Delphi')
driver.find_element_by_id("su").click()
#关闭浏览器进程
#driver.quit()