在 chrome 文件夹,打开cmd,输入命令
chrome.exe --remote-debugging-port=9222 --user-data-dir=“C:\selenum\AutomationProfile”
from time import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
chrome_driver = r'F:\chromeDriver\1000489660\chromedriver_win32\chromedriver.exe'
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)
print(driver.title)
特殊点击方法
element = driver.find_element_by_xpath('(//*[@class="be-dropdown fans-action-btn fans-action-follow"])['+str(i)+']/ul/li[2]')
driver.execute_script("arguments[0].click();", element)