from selenium.webdriver import Chrome
import time
from selenium import webdriver
option = webdriver.ChromeOptions()
option.add_experimental_option(
'excludeSwitches',
['enable-automation'])
driver = webdriver.Chrome(chrome_options=option)
driver.maximize_window()
driver.get('http://www.porters.vip/features/webdriver.html')
#定位按钮并点击
driver.find_element_by_css_selector('.btn.btn-primary.btn-lg').click()
#定位到文章内容元素
elements = driver.find_element_by_css_selector('#content')
time.sleep(1)
print(elements.text)
driver.close()
以开发者模式运行selenium