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. Git版本退回和修改

    首先我们来看看我们的第一个版本: 我的git文件如下: 那我们来修改一下这个文件 然后提交 那我们来查看一下提交的记录:使用git log 当我们使用 git log --pretty=oneline ...

  2. 解决cocos2dx调用removeFromParent后报错问题

    原因:cocos2dx的bug 解决办法: 放到action中,前面添加一个DelayTime延迟,代码如下 this->runAction(Sequence::create(DelayTime ...

  3. HDU - 3982:Harry Potter and J.K.Rowling(半平面交+圆与多边形求交)(WA ing)

    pro:给定一枚蛋糕,蛋糕上某个位置有个草莓,寿星在上面切了N刀,最后寿星会吃含有草莓的那一块蛋糕,问他的蛋糕占总蛋糕的面积比. sol:显然需要半平面交求含有蛋糕的那一块,然后有圆弧,不太方便求交. ...

  4. CodeForces - 441D: Valera and Swaps(置换群)

    A permutation p of length n is a sequence of distinct integers p1, p2, ..., pn (1 ≤ pi ≤ n). A permu ...

  5. NYOJ 12:喷水装置(二)(贪心,区间覆盖问题)

    12-喷水装置(二) 内存限制:64MB 时间限制:3000ms 特判: No 通过数:28 提交数:109 难度:4 题目描述: 有一块草坪,横向长w,纵向长为h,在它的橫向中心线上不同位置处装有n ...

  6. 第一次Scrum会议(10/13)【欢迎来怼】

    一.小组信息 队名:欢迎来怼 小组成员 队长:田继平 成员:李圆圆,葛美义,王伟东,姜珊,邵朔,冉华 小组照片 二.开会信息 时间:2017/10/13 16:22~16:47,总计25min. 地点 ...

  7. linux下如何执行.sh文件 【转】

    Linux下如何运行.sh文件 是UNIX/LINUX 操作系统的脚本文件,SHELL文件. 本文转载自 http://whitepoplar.javaeye.com/blog/431967 Linu ...

  8. 基于Flask开发web微信

    1. 获取二维码 app.py import re import time import requests from flask import Flask,render_template app = ...

  9. ubuntu shell插件

    1. NetSpeed 在状态栏显示当前网速 2. Screenshot Tool 同样在 Ubuntu 18.04 之前我们使用 Shutter,但在Ubuntu 18.04 Shutter的托盘图 ...

  10. C++中的智能指针、轻量级指针、强弱指针学习笔记

    一.智能指针学习总结 1.一个非const引用无法指向一个临时变量,但是const引用是可以的! 2.C++中的delete和C中的free()类似,delete NULL不会报"doubl ...