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. supervisor-program配置

    [program:check_server_state]directory=/sunlight/shellcommand=/usr/bin/sh check_server_state.shautost ...

  2. Unity 3D-AR开发-Vuforia教程手册

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

  3. 20155219 2016-2017-2 《Java程序设计》第6周学习总结

    20155219 2016-2017-2 <Java程序设计>第6周学习总结 教材学习内容总结 串流设计 1.串流:Java将输入/输出抽象化为串流,数据有来源及目的地,衔接两者的是串流对 ...

  4. sed 等相关的复习

    sed相打印两行之间的内容: sed -n '/111/,/aad/p' fuxi.txt grep -n ".*" fuxi.txt sed -n '2,9'p fuxi.txt ...

  5. Python数据结构——栈的链表实现

    自定义链表实现栈的数据结构,代码如下: class Stack: def __init__(self): self._first = None def push(self,item): self._f ...

  6. YIT-CTF—社工类

    下载图片

  7. 【java编程】Java魔法类:Unsafe应用解析

    转载来源:https://tech.meituan.com/2019/02/14/talk-about-java-magic-class-unsafe.html 前言 Unsafe是位于sun.mis ...

  8. 反射,内省,BeanUtil的区别

    PS:为了操作反射方便,sun创建了 内省, Apache闲麻烦自己创建了BeanUtils 1.开发框架时,经常需要使用java对象的属性来封装程序的数据,每次都使用反射技术完成此类操作过于麻烦,所 ...

  9. 小D课堂【SpringBoot】接口Http协议开发实战

    ---恢复内容开始--- ====================2.SpringBoot接口Http协议开发实战 ============================= 1.SpringBoot ...

  10. 在Android上运行Java和C程序

    在linux上运行java程序,直接用javac编译,再用java启动虚拟机运行就行了.但是在Android上,由于虚拟机和pc端的不同,所以操作方法也是不一样的.下面介绍Android上运行Hell ...