python selenium基本
基本
from selenium import webdriver
import re driver = webdriver.Firefox()
driver.get('https://www.google.com') main_window = driver.current_window_handle driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't') element = driver.find_element_by_xpath("/html/body/div[2]/div[1]/table/tbody/tr[2]/td[6]")
actions = ActionChains(driver)
actions.move_to_element(element1)
actions.perform() path = ‘/html/body/div[2]/div/ul/li/a'
color_rgb = driver.find_element_by_xpath(path).value_of_css_property('color')
rgb_values = re.match( r'\w+\((.*), (.*), (.*), \d+\)', color_rgb)
red = rgb_values.group(1)
green = rgb_values.group(2)
blue = rgb_values.group(3) alert = driver.switch_to_alert()
print alert.text
required_text = "Login failed"
if alert.text != required_text:
print 'ERROR'
alert.accept() while(driver.find_element_by_xpath("/html/body/div/form/div[1]/input").is_displayed()):
driver.find_element_by_xpath("/html/body/div/form/div[1]/input").click() if not driver.find_element_by_id('checkitem').is_selected():
driver.find_element_by_id('checkitem').click() driver.find_element_by_id('username').clear() key = driver.find_element_by_xpath('//tr[@class="dataView otr"][%d]/td[1]'%i).text.strip()
python selenium基本的更多相关文章
- python+selenium 浏览器的问题
以前用selenium调用firefox是不需要驱动的,最近安装了python3.52+最新的firefox 发现调不起来了 搜索以后发现Firefox 47+需要搞个firefox的驱动 gecko ...
- 一次完整的自动化登录测试-基于python+selenium进行cnblog的自动化登录测试
Web登录测试是很常见的测试!手动测试大家再熟悉不过了,那如何进行自动化登录测试呢!本文作者就用python+selenium结合unittest单元测试框架来进行一次简单但比较完整的cnblog自动 ...
- Python + Selenium 实现登录Office 365
最近捡起之前用的Python + Selenium实现工作中需要的登录Office 365功能.(吐槽:国内网络真是卡,登录Office 365实属不易.另外Selenium这样的网站都要墙,无法理解 ...
- python+selenium+Robot
准备工作: 1.下载python2.7 http://python.org/getit/ 2.下载下载setuptools [python 的基础包工具] 可以帮助我们轻松的下载,构建,安装,升级,卸 ...
- python+selenium运行报错UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
使用python+selenium运行自动化脚本时,打印某一段文字出现UnicodeEncodeError: 'ascii' codec can't encode characters in posi ...
- Functional testing - python, selenium and django
Functional testing - python selenium django - Source Code : from selenium import webdriverfrom sele ...
- python selenium自动化(二)自动化注册流程
需求:使用python selenium来自动测试一个网站注册的流程. 假设这个网站的注册流程分为三步,需要提供比较多的信息: 在这个流程里面,需要用户填入信息.在下拉菜单中选择.选择单选的radio ...
- 使用python selenium进行自动化functional test
Why Automation Testing 现在似乎大家都一致认同一个项目应该有足够多的测试来保证功能的正常运作,而且这些此处的‘测试’特指自动化测试:并且大多数人会认为如果还有哪个项目依然采用人工 ...
- Python+Selenium WebDriver API:浏览器及元素的常用函数及变量整理总结
由于网页自动化要操作浏览器以及浏览器页面元素,这里笔者就将浏览器及页面元素常用的函数及变量整理总结一下,以供读者在编写网页自动化测试时查阅. from selenium import webdrive ...
- Python Selenium设计模式-POM
前言 本文就python selenium自动化测试实践中所需要的POM设计模式进行分享,以便大家在实践中对POM的特点.应用场景和核心思想有一定的理解和掌握. 为什么要用POM 基于python s ...
随机推荐
- java中部分知识点的验证实现
java中运算符重载 满足以下条件的两个或多个方法构成"重载"关系: (1)方法名相同: (2)参数类型不同,参数个数不同,或者是参数类型的顺序不同. 注意:方法的返回值不作为方法 ...
- Golang的"泛型"模式
只要实现了Sortable接口的所有方法,就可以使用该接口的函数. 我们通过冒泡排序来演示一下: package main import "fmt" type Sortable i ...
- 解决ubuntu下的firefox无法在线播放音频和视频的问题
一贯无视 Linux 平台的腾讯(无贬义)理所当然地没有开发QQ音乐Linux版,于是想尝试QQ音乐网页版,结果发现歌曲无法播放.刚开始以为是腾讯还在网页版上用万恶的 Windows Media Pl ...
- zoj 2770 Burn the Linked Camp
今天刚刚学差分约束系统.利用最短路求解不等式.世界真的好奇妙!感觉不等式漏下几个会导致WA!! #include<cstdio> #include<cstring> #incl ...
- js---DOM元素节点
创建新的 HTML 元素如需向 HTML DOM 添加新元素,您必须首先创建该元素(元素节点),然后向一个已存在的元素追加该元素. 实例1: <!DOCTYPE html> <htm ...
- HDU 1331 Function Run Fun(记忆化搜索)
Problem Description We all love recursion! Don't we? Consider a three-parameter recursive function w ...
- css实现三列布局,左右固定值,中间自适应。
这里主要用到的是position:absolute;及margin属性;代码很简单,一看就明白. <!DOCTYPE html> <html lang="zh_CN&quo ...
- uhttpd配置文件分析
文件位于 /etc/config/uhttpd. root@hbg:/etc/config# cat uhttpd config uhttpd 'main' list listen_ht ...
- CentOS postgresql9.4
yum install http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm Once t ...
- 我所使用的Linux软件集合
自从2003-2004春节之际初次尝试使用Linux以来,至今已十年有余了.尤其是整个博士研究期间,坚持在Linux下开展学习与研究工作,前前后后试用了不少桌面环境.窗口管理器.终端程序以及其他应用软 ...