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.的更多相关文章

  1. Python+Selenium 利用ID,XPath,tag name,link text,partial link text,class name,css,name定位元素

    使用firefox浏览器,查看页面元素,我们以“百度网页”为示例 一.ID定位元素    利用find_element_by_id()方法来定位网页元素对象 ①.定位百度首页,输入框的元素 ②.编写示 ...

  2. Python+selenium学习(一) 打开Firefox浏览器,IE浏览器和Chrome浏览器

    from selenium import webdriver # open Firefox #driver=webdriver.Firefox() # Open IE #driver=webdrive ...

  3. python+selenium 元素被定位到而且click()也提示执行成功,但是页面就是没有变化和跳转。

    python+selenium 元素被定位到而且click()也提示执行成功,但是页面就是没有变化和跳转. 如果多次定位和click(),有时候会跳转. 我遇到很多次就是很郁闷,有人说,操作太快的,页 ...

  4. python selenium 元素定位(三)

    上两篇的博文中介绍了python selenium的环境搭建和编写的第一个自动化测试脚本,从第二篇的例子中看出来再做UI级别的自动化测试的时候,有一个至关重要的因素,那就是元素的定位,只有从页面上找到 ...

  5. python+selenium自动化软件测试(第2章):WebDriver API

    2.1 操作元素基本方法 前言前面已经把环境搭建好了,从这篇开始,正式学习selenium的webdriver框架.我们平常说的 selenium自动化,其实它并不是类似于QTP之类的有GUI界面的可 ...

  6. Python selenium自动化网页抓取器

    (开开心心每一天~ ---虫瘾师) 直接入正题---Python selenium自动控制浏览器对网页的数据进行抓取,其中包含按钮点击.跳转页面.搜索框的输入.页面的价值数据存储.mongodb自动i ...

  7. python selenium自动化点击页面链接测试

    python selenium自动化点击页面链接测试 需求:现在有一个网站的页面,我希望用python自动化的测试点击这个页面上所有的在本窗口跳转,并且是本站内的链接,前往到链接页面之后在通过后退返回 ...

  8. Python+Selenium笔记(十四)鼠标与键盘事件

     (一) 前言 Webdriver高级应用的API,允许我们模拟简单到复杂的键盘和鼠标事件,如拖拽操作.快捷键组合.长按以及鼠标右键操作,都是通过使用webdriver的Python API 中的Ac ...

  9. Python selenium.webdriver.chrome.options.Options() Examples

    The following are 27 code examples for showing how to use selenium.webdriver.chrome.options.Options( ...

随机推荐

  1. paddle——docker实践

    Docker image阅读:https://github.com/PaddlePaddle/book/blob/develop/README.cn.md docker run -d -p 8888: ...

  2. 百练1041-反反复复-2016正式C题

    C:反反复复 总时间限制:  1000ms 内存限制:  65536kB 描述 Mo和Larry发明了一种信息加密方法.他们首先决定好列数,然后将信息(只包含字母)从上往下依次填入各列,并在末尾补充一 ...

  3. Unity 3D动态修改Shader状态,使物体透明等等

    Unity动态改Shader状态透明 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...

  4. RuntimeError: Broken toolchain: cannot link a simple C program

    今天Python2.7下安装numpy的时候遇到了此错误,进过查阅发现以下方法可行 在Python27\Lib\distutils\msvc9compiler.py 文件中,找到 mfinfo = s ...

  5. SEO:关键词布局

  6. STM32F4的sct文件理解

    原文地址http://blog.sina.com.cn/s/blog_898f36590100ya2l.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...

  7. LeetCode - Boundary of Binary Tree

    Given a binary tree, return the values of its boundary in anti-clockwise direction starting from roo ...

  8. cget cmake 包管理工具

    cget 是一个方便的进行cmake 包下载以及安装的工具 包含的特性 非侵入,无需编写特殊钩子就可以使用cmake 开箱即用, 由于使用了标准的基于cmake的方式,直接可以使用基于cmkae 的软 ...

  9. Singer 学习七 运行&&开发taps、targets (二 targets 运行说明)

    接上文: Singer 学习六 运行&&开发taps.targets (一 taps 运行说明) 说明target 需要tap 进行配合运行,所以需要了解tap 的使用 运行targe ...

  10. lapis 项目添加prometheus 监控集成grafana

    操作很简单,主要是进行界面的配置以及prometheus 服务的配置, 可以和https://www.cnblogs.com/rongfengliang/p/10074044.html &&a ...