【发布时间】:2016-11-05 07:11:32
【问题描述】:
我正在尝试使用 Python、Chrome 和 ActionChains 来保存网页。
代码似乎在一台计算机上运行良好,但在另一台计算机上却不行。
我检查了代码,也尝试了selenium action chains no effect 给出的建议,但还是不行。
哪里出错了?谢谢。
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import win32com.client as comclt
chromedriver = "c:\Python27\\chromedriver.exe"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.maximize_window()
aaa = driver.get("https://sg.yahoo.com/?p=us")
time.sleep(3)
save_me = ActionChains(driver).key_down(Keys.CONTROL).key_down('s').key_up(Keys.CONTROL).key_up('s')
save_me.perform()
time.sleep(2)
wsh= comclt.Dispatch("WScript.Shell")
wsh.AppActivate("chrome")
time.sleep(1)
wsh.SendKeys("{ENTER}")
driver.quit()
【问题讨论】:
标签: python selenium-chromedriver