码迷,mamicode.com
首页 > 编程语言 > 详细

python selenium right click on an href and choose Save link as... on Chrome.

时间:2018-11-29 12:26:20      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:get   open   import   select   chain   tty   pytho   ext   代码   

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‘])
 

python selenium right click on an href and choose Save link as... on Chrome.

标签:get   open   import   select   chain   tty   pytho   ext   代码   

原文地址:https://www.cnblogs.com/Raul2018/p/10037177.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!