Raul2018

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
From:https://stackoverflow.com/questions/42781483/right-click-on-an-href-and-choose-save-link-as-in-python-selenium/42783015
原生代码:
from selenium import webdriver from selenium.webdriver import ActionChains
import pyautogui
driver = webdriver.Chrome() driver.get(link) elem = driver.find_element_by_css_selector('a[target="_blank"]') actionChain = ActionChains(driver) actionChain.context_click(elem).perform()
pyautogui.typewrite(['down','down','down','down','enter'])

我的代码:
def test_bzw_install(self):
__download_arrow = (By.CLASS_NAME, 'glyphicon-arrow-right')
__bluezone_web_build_logo = (By.CLASS_NAME, 'no-text-decoration')
"""1.Download latest build from bzw Build web site(http://10.17.10.130/bzw) to local"""
"""1.1.Open Build web site(http://10.17.10.130/bzw)"""
self.driver = BaseWebDriver().getDriver(Global().browser)
self.build_page = BzwInstall(self.driver)
self.build_page.go_to()
# """1.2(PlanA).Click Master Download Arrow to download-Pass"""
self.ele_visible_short(self.__bluezone_web_build_logo)
elem_download_arrow = self.get_elements(*self.__download_arrow)[0]
actionChain = ActionChains(self.driver)
actionChain.context_click(elem_download_arrow).perform()
pyautogui.typewrite(['down', 'down', 'down', 'down', 'enter'])
 
posted on 2018-11-29 11:22  Raul2018  阅读(506)  评论(0编辑  收藏  举报