python selenium 完整测试脚本
2013-01-06 12:39
513 查看
#-*- coding: utf-8 -*-
'''在python脚本中应用中文'''
'''应用selenium'''
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
#访问管理工具
driver = webdriver.Chrome()
driver.get("http://172.16.22.114/tms/")
#选择测试管理
clicktestmanager = driver.find_element_by_name("Image8")
clicktestmanager.click()
print driver.title
#输入用户名密码登录到项目选择
inputusername = driver.find_element_by_id("textfield")
inputusername.send_keys("zrs")
inputpassword = driver.find_element_by_id("password")
inputpassword.send_keys("ccidcstc")
buttonlogin = driver.find_element_by_name("Image16")
buttonlogin.click()
print driver.title
#选择项目
select = driver.find_element_by_id("select")
allption = select.find_elements_by_tag_name("option")
for option in allption:
print "Text is " + option.text+"; Value is "+option.get_attribute("value")
selectproject = Select(select)
selectproject.select_by_value("71")
#登录系统
clicklogin = driver.find_element_by_name("Image15")
clicklogin.click()
driver.switch_to_frame("foot")
driver.switch_to_frame("leftFrame")
clickaddq = driver.find_element_by_id("ImageButton1")
clickaddq.click()
try:
elementwait = WebDriverWait(driver,20).until(lambda driver:driver.find_element_by_id("ImageButton1"))
clickaddq = driver.find_element_by_id("ImageButton1")
clickaddq.click()
finally:
print driver.title
'''在python脚本中应用中文'''
'''应用selenium'''
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
#访问管理工具
driver = webdriver.Chrome()
driver.get("http://172.16.22.114/tms/")
#选择测试管理
clicktestmanager = driver.find_element_by_name("Image8")
clicktestmanager.click()
print driver.title
#输入用户名密码登录到项目选择
inputusername = driver.find_element_by_id("textfield")
inputusername.send_keys("zrs")
inputpassword = driver.find_element_by_id("password")
inputpassword.send_keys("ccidcstc")
buttonlogin = driver.find_element_by_name("Image16")
buttonlogin.click()
print driver.title
#选择项目
select = driver.find_element_by_id("select")
allption = select.find_elements_by_tag_name("option")
for option in allption:
print "Text is " + option.text+"; Value is "+option.get_attribute("value")
selectproject = Select(select)
selectproject.select_by_value("71")
#登录系统
clicklogin = driver.find_element_by_name("Image15")
clicklogin.click()
driver.switch_to_frame("foot")
driver.switch_to_frame("leftFrame")
clickaddq = driver.find_element_by_id("ImageButton1")
clickaddq.click()
try:
elementwait = WebDriverWait(driver,20).until(lambda driver:driver.find_element_by_id("ImageButton1"))
clickaddq = driver.find_element_by_id("ImageButton1")
clickaddq.click()
finally:
print driver.title
相关文章推荐
- Python+Selenium基础篇之5-第一个完整的自动化测试脚本
- python 自动化测试脚本-->selenium应用
- 【一】web自动化测试<selenium2+python>环境搭建+脚本测试执行
- selenium python 测试google脚本
- selenium+python关于登录的脚本代码,使用了读取excel以及向excel中写入测试结果的方法
- 一次完整的自动化登录测试-基于python+selenium进行cnblog的自动化登录测试 推荐
- 一次完整的自动化登录测试-基于python+selenium进行cnblog的自动化登录测试
- python-day0003-搭建基于python的selenium自动化测试---第一个简单的测试脚本
- 一次简单完整的自动化登录测试-基于python+selenium进行cnblog的自动化登录测试
- Python+Selenium框架设计篇之9-unittest执行脚本方法之makeSuite()
- selenium+python测试全部用例
- http响应状态码测试脚本(python版)
- Python脚本解决一些繁琐的测试问题
- Python3+Selenium2(Webdriver)第一个自动化脚本
- python+selenium 自动化测试入门示例(邮件发送)
- 【python】解析Excel中使用xlrd库、xlwt库操作,写入excel进阶完整脚本实例(五)
- 编写Python小程序来统计测试脚本的关键字
- Python脚本控制的WebDriver 常用操作 <十七> 获取测试对象的属性及内容
- selenium.WebDriver 自动化测试脚本