我正在研究一些脚本来使用selenium和python下载chrome扩展程序。
from time import sleep
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
options = Options()
#options.headless = True
options.add_argument('--no-sandbox')
options.add_argument("--disable-infobars")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--remote-debugging-port=9222")
options.add_argument("--disable-web-security")
options.add_argument("--allow-running-insecure-content")
# options.add_argument("--user-data-dir=/Users/sachin/Library/Application Support/Google/Chrome")
try:
driver = webdriver.Chrome(chrome_options=options)
driver.get("https://chrome.google.com/webstore/detail/adblock/dgpfeomibahlpbobpnjpcobpechebadh?hl=en-US")
sleep(5)
add_to_chrome = driver.find_element_by_xpath('//div[contains(text(), "{0}")]'.format("Add to Chrome"))
if add_to_chrome:
add_to_chrome.click()
sleep(10)
# I am stuck after this part.
except:
import traceback
traceback.print_exc()
pass
我单击“添加到Chrome按钮”,然后出现一个带有“添加扩展程序按钮”的弹出窗口,但我无法单击它。任何帮助将不胜感激。