python+selenium链接对象操作
对于链接对象常见的操作有:单击、获取链接文字、获取链接地址等:
from selenium import webdriver
from time import sleep driver = webdriver.Firefox() # 指定和打开浏览器
url1='http://www.baidu.com'
driver.get(url1) #打开第一个网址 #也可以写成:driver.get('http://www.baidu.com')
sleep(5) #<a href="http://map.baidu.com" name="tj_trmap" class="mnav">地图</a> print(driver.find_element_by_link_text('地图').get_attribute('class')) # mnav
print(driver.find_element_by_link_text('地图').get_attribute('name')) # tj_trmap
print(driver.find_element_by_link_text('地图').get_attribute('href')) # http://map.baidu.com/
print(driver.find_element_by_link_text('地图').get_attribute('text')) #地图 #获取元素标签内的内容 driver.find_element_by_link_text('地图').click()
sleep(30)
python+selenium链接对象操作的更多相关文章
- python selenium 基本常用操作
最近学习UI自动化,把一些常用的方法总结一下,方便自己以后查阅需要.因本人水平有限,有不对之处多多包涵!欢迎指正! 一.xpath模糊匹配定位元素 武林至尊,宝刀屠龙刀(xpath),倚天不出(css ...
- python selenium鼠标键盘操作(ActionChains)
用selenium做自动化,有时候会遇到需要模拟鼠标操作才能进行的情况,比如单击.双击.点击鼠标右键.拖拽等等.而selenium给我们提供了一个类来处理这类事件--ActionChains sele ...
- python+selenium 鼠标事件操作
一.前言 除了可以使用 click( ) 来模拟鼠标的单击操作,现在Web产品中还提供了更丰富的鼠标交互方式,例如鼠标右键.双击.悬停.拖动等功能,在WebDriver中,将这些关于鼠标操作的方法都封 ...
- python selenium模拟滑动操作
selenium.webdriver提供了所有WebDriver的实现,目前支持FireFox.phantomjs.Chrome.Ie和Remote quit()方法会退出浏览器,而close()方法 ...
- python+selenium高亮显示正在操作的页面元素
原文地址:https://blog.csdn.net/wxstar8/article/details/80801405 from selenium import webdriver import un ...
- 8 Python+Selenium操作测试对象
[环境信息] Python3.6+selenium3.0.2+Firefox50.0+win7 [操作方法] 1.清除输入框内容:clear() 2.单击一个按钮:click() 3.返回元素尺寸:s ...
- python selenium鼠标滑动操作
先安装pyautogui: pip install pyautogui #coding=utf-8 import pyautogui from selenium import webdriver fr ...
- python+selenium模拟鼠标操作
from selenium.webdriver.common.action_chains import ActionChains #导入鼠标相关的包 ------------------------- ...
- python selenium 获取对象输入的属性值
.get_attribute("value") from selenium import webdriver import time driver=webdriver.Firefo ...
随机推荐
- 使用Medusa美杜莎暴力破解SSH密码
使用Medusa美杜莎暴力破解SSH密码 1.Medusa简介 Medusa(美杜莎)是一个速度快,支持大规模并行,模块化的爆力破解工具.可以同时对多个主机,用户或密码执行强力测试.Medusa和hy ...
- 数据结构课后练习题(练习一)1007 Maximum Subsequence Sum (25 分)
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to ...
- Educational Codeforces Round 68 (Rated for Div. 2) D. 1-2-K Game (博弈, sg函数,规律)
D. 1-2-K Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input ou ...
- 生成对抗网络 Generative Adversarial Networks
转自:https://zhuanlan.zhihu.com/p/26499443 生成对抗网络GAN是由蒙特利尔大学Ian Goodfellow教授和他的学生在2014年提出的机器学习架构. 要全面理 ...
- [易学易懂系列|golang语言|零基础|快速入门|(一)]
golang编程语言,是google推出的一门语言. 主要应用在系统编程和高性能服务器编程,有广大的市场前景,目前整个生态也越来越强大,未来可能在企业应用和人工智能等领域占有越来越重要的地位. 本文章 ...
- case_match
//箭头符号 => 隔开了模式和表达式.//选择器 match {备选项}.//只要发现有一个匹配的case,剩下的case不会继续匹配. //object case_test {//// de ...
- 安装suds,提示No module named 'client'
最近在研究webservice,但是在线安装suds的时候提示No module named 'client' 提示没有client模块,提示这个错误主要还是因为没有安装client模块 在线安装cl ...
- Linux下Centos7对外开放端口
转载:https://blog.csdn.net/realjh/article/details/82048492 命令集合: ()查看对外开放的端口状态 查询已开放的端口 netstat -anp 查 ...
- Java面试之集合框架篇(3)
21.ArrayList和Vector的区别 这两个类都实现了List接口(List接口继承了Collection接口),他们都是有序集合,即存储在这两个集合中的元素的位置都是有顺序的,相当于一种动态 ...
- (js)粘贴时去掉HTML格式
一.IE能够触发onbeforepaste事件,因此可以在该事件中直接改变剪贴板中的内容实现过滤效果 二.谷歌由于不能触发onbeforepaste,先阻止默认行为,通过window.getSelec ...