Web自动化测试(全网最给力自动化教程)【selenium功能测试+requests/jmeter/postman接口测试+Loadrunner性能测试】

——让爱学习的人汇聚在一起,让想涨工资的人来此地安心学习,让不想花钱就想学到最新软件测试的人得到更多的知识!(Web软件测试自动化爱好者协会创办,始创于2017.8.25)

导航

python+selenium自动化软件测试(第16章):基础实战(3)

#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.Firefox()

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.Firefox()
        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('cntanght@163.com','xxxxx','www.baidu.com、'1.0.0.1’)
test.add_info()

 

posted on 2017-08-27 10:07  Web自动化测试  阅读(1577)  评论(0编辑  收藏  举报