作者在 2016-03-24 09:22:52 发布以下内容
注册7条case#-*- coding:UTF-8 -*- # 解码方式 __author__ = 'pop' from selenium import webdriver import time def testLogin(testname,testpassword,revtype,realvalue): bruce = webdriver.Firefox() #start firfox brower .bruce定义为火狐浏览器 bruce.maximize_window() # max windows bruce.get("http://192.168.242.128:8088/Tinyshop/") # url time.sleep(3) bruce.find_element_by_link_text("注册").click() bruce.find_element_by_id("email").send_keys(testname) bruce.find_element_by_name("password").send_keys(testpassword) bruce.find_element_by_name("repassword").send_keys(testpassword) bruce.find_element_by_name("verifyCode").send_keys("1111") bruce.find_element_by_id("readme").click() bruce.find_element_by_class_name("btn").click() #actvalue = bruce.find_element_by_xpath(".//*[@id='content']/div/div/div[1]").text actvalue = bruce.find_element_by_xpath(revtype).text print actvalue #bruce.implicitly_wait(3) if realvalue == actvalue: print "ok" else: print "suck my dick" time.sleep(3) bruce.close() #testLogin("5546464@qq.com","a123456","恭喜您,注册成功!") testLogin("55464645@qq.com","123456",".//*[@id='content']/div/div/div[1]",u"恭喜您,注册成功!") time.sleep(2) testLogin("5546@qq.com","123",".//*[@id='content']/div/div[1]/div[2]/form/dl[2]/dd/label",u"6-20任意字符组合") time.sleep(2) testLogin("5546@qq.com","123",".//*[@id='content']/div/div[1]/div[2]/form/dl[2]/dd/label",u"6-20任意字符组合") time.sleep(2) testLogin("5546@qq.com","123",".//*[@id='content']/div/div[1]/div[2]/form/dl[2]/dd/label",u"6-20任意字符组合") time.sleep(2) testLogin("5546@qq.com","123",".//*[@id='content']/div/div[1]/div[2]/form/dl[2]/dd/label",u"6-20任意字符组合")
-----------------
指定网页寻找输出天数
#-*- coding:UTF-8 -*- # 解码方式
__author__ = 'pop' #标名必须有效,否则会出错
from selenium import webdriver
import sys
def findnextpage1():
lee.find_element_by_xpath(".//*[@id='pagination']/ul/li[14]/a").click()
for i in range(1,11):
title = lee.find_element_by_xpath("html/body/div[1]/section/div/div[2]/div/div[1]/div["+str(i)+"]/div/div[1]/h3/span").text
if title == u"100起投,长兴8号337-5":
label = lee.find_element_by_xpath("html/body/div[1]/section/div/div[2]/div/div[1]/div["+str(i)+"]/div/div[1]/div[2]/p[1]/em").text
print label
sys.exit()
else:
print "suck"
findnextpage1()
def findonepage():
global lee
global title
lee = webdriver.Firefox()
lee.maximize_window()
lee.get("http://www.firstp2p.com/deals?cate=16")
for i in range(5,11):
title = lee.find_element_by_xpath("html/body/div[1]/section/div/div[2]/div/div[1]/div["+str(i)+"]/div/div[1]/h3/span").text
if title == u"100起投,长兴8号337-5":
label = lee.find_element_by_xpath("html/body/div[1]/section/div/div[2]/div/div[1]/div["+str(i)+"]/div/div[1]/div[2]/p[1]/em").text
print label
break
else:
print "suck"
findnextpage1()
findonepage()
----
#-*- coding:UTF-8 -*- # 解码方式
__author__ = 'pop'
from selenium import webdriver
def suck():
lee = webdriver.Firefox()
lee.maximize_window()
lee.get("http://www.firstp2p.com/")
webtitle = lee.title
time.sleep(2)
lee.find_element_by_xpath(".//*[@id='top_nav']/ul/li[2]/a").click()
time.sleep(2)
nettitle = lee.title
time.sleep(2)
lee.back()
if lee.title == webtitle:
print "successfully"
lee.forward()
if nettitle == lee.title:
print "successfully"
else:
print "failed.try again"
else:
print "failed.try again"
lee.close()
suck()
#-*- coding:UTF-8 -*- # 解码方式
__author__ = 'pop'
def cmp(): #无参有返回
import xlrd #需要安装xlrd
book = xlrd.open_workbook("/Users/poptest/Downloads/login.xlsx")
sheet = book.sheet_by_name("abc")
if sheet.cell(0,0).value == a and sheet.cell(0,1).value == b:
return "Congratalation,login successfully"
else:
return "username or password error , please try again"
# login captain
a = raw_input("please enter username")
b = input("please enter password")
c = raw_input("please enter x if you want login")
if c == "x":
print(cmp())
else:
print "enter wrong,please try again"
#-*- coding:UTF-8 -*- # 解码方式
__author__ = 'popt'
def cmp(username,password): #传参有返回,logining
import xlrd
book = xlrd.open_workbook("/Users/poptest/Downloads/login.xlsx")
sheet = book.sheet_by_name("abc")
j = sheet.nrows
for i in range(0,j):
if sheet.cell(i,0).value == username and sheet.cell(i,1).value == password:
print "Congratelation,Login Successfully"
else:
print "Login error .Please try again"
# login captain
a = raw_input("please enter username")
b = input("please enter password")
c = raw_input("please enter x if you want login")
if c == "x":
cmp(a,b)
exit