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 ...
随机推荐
- 不同浏览器对URL最大长度的限制
不同浏览器对URL最大长度的限制 1.今天碰到一个bug,window.open后面的页面,接收参数不全,导致后台报错.实验了一下.发现是使用get方法请求服务器时,URL过长所致 微软官方的说明 ...
- wpf 控件截屏
/// <summary> /// 保存截图 /// </summary> /// <param name="ui">控件名称</para ...
- linux下卸载和安装mysql数据库的方法
1.1 MySQL下载 下载地址:http://www.mysql.com/downloads/mysql/5.5.html#downloads 版本:5.1.68 平台:linux general ...
- maven创建spring项目之后,启动报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoade
错误: org.apache.catalina.core.StandardContext listenerStart严重: Error configuring application listener ...
- 第一百一十三节,JavaScript文档对象,DOM基础
JavaScript文档对象,DOM基础 学习要点: 1.DOM介绍 2.查找元素 3.DOM节点 4.节点操作 DOM(Document Object Model)即文档对象模型,针对HTML和XM ...
- 第八十二节,CSS3过渡效果
CSS3过渡效果 学习要点: 1.过渡简介 2.transition-property 3.transition-duration 4.transition-timing-function 5.tra ...
- Marble 绘制线
#include <QtGui/QApplication> #include <marble/MarbleWidget.h> #include <marble/GeoPa ...
- 转Delphi中Create(nil),Create(self),Create(Application)区别
Create(nil);//需要自己释放 Create(Self);//当Self释放时自动触发释放 Create(Application);//当Application释放时自动释放 Create( ...
- D - 小Y上学记——要迟到了!
D - 小Y上学记——要迟到了! Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) ...
- 【code vs】 2780 ZZWYYQWZHZ
2780 ZZWYYQWZHZ 题目描述 Description 可爱的小管在玩吹泡泡.忽然,他想到了一种排序....... 输入描述 Input Description 第一行输入n,表示有n个数. ...