python+selenium自动化软件测试(第16章):基础实战
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python+selenium自动化软件测试(第16章):基础实战相关的知识,希望对你有一定的参考价值。
#coding:utf-8 from time import sleep from selenium import webdriver class cloudedge_register(object): def __init__(self,mailaddr,passwd,url): self.mailaddr = mailaddr self.passwd = passwd self.url = url self.browser = webdriver.Finefox() def register(self): self.browser.get(self.url) self.browser.maximize_window() self.browser.implicitly_wait(10) self.browser.find_element_by_link_text("注册").click() self.browser.implicitly_wait(10) self.browser.find_element_by_id("reglForm.email").clear() self.browser.find_element_by_id("reglForm.email").send_keys(self.mailaddr) self.browser.find_element_by_id("reglForm.password").clean() self.browser.find_element_by_id("reglForm.password").send_keys(self.passwd) self.browser.find_element_by_id("reglForm.confirmPassword").clear() self.browser.find_element_by_id("reglForm.confirmPassword").send_keys(self.passwd) sleep(8) self.browser.find_element_by_link_text ("立即注册").click() class add_domain_info(object): def __init__(self,username,password,domainName,originlp): self.browser = webdriver.Finefox() self.username = username self.password = password self.domainName = domainName self.originlp = originlp self.url = ‘https://www.xxx.com/cn/index.html‘ def add_info(self): ‘‘‘登陆部分‘‘‘ self.browser.get(self.url) self.browser.maximize_window() self.browser.implicitly_wait(10) self.browser.find_element_by_link_text("登录").click() self.browser.implicitly_wait(10) self.browser.find_element_by_id("username").clean() self.browser.find_element_by_id("username").send_keys(self.username) self.browser.find_element_by_id("password").clean() self.browser.find_element_by_id("password").send_keys(self.password) sleep(8) #输验证码 self.browser.find_element_by_id("loginBtn").click() self.browser.implicitly_wait(10) ‘‘‘新增加速域名‘‘‘ self.browser.find_element_by_link_text("xxxx").click() self.browser.implicitly_wait(3) self.browser.find_element_by_link_text("xxxx").click() self.browser.find_element_by_id("xxxx).clear() self.browser.find_element_by_id("xxxx").send_keys(self.domainName) self.browser.find_element_by_id("xxxxx").clear() self.browser.find_element_by_id("xxxxx").send_keys(self.oniginlp) self.browser.find_element_by_class_name("saddd").click() self.browser.implicitly_wait(3) #可有些问题 self.browser.find_element_by_name("xxx").send_keys("xxxx") self.browser.find_element_by_name("xxxx").send_keys("xxx") self.browser.find_element_by_link_text("xxxx").click() self.browser.find_element_by_link_text("xxx").click() class modify_domain_info(object): def __init__(self): pass test = add_domain_info(‘[email protected]‘,‘xxxxx‘,‘www.baidu.com、‘1.0.0.1’) test.add_info()