Exemple #1
0
    def test_search_mail1(self):
        driver = self.driver
        driver.get(self.base_url)
        self.driver.implicitly_wait(30)

        #登录
        login.login(self)

        driver.switch_to_default_content()

        #搜索邮件
        driver.find_element_by_xpath("//input[@class='nui-ipt-input' and \
                                    @type='text']").send_keys(u'小明')
        time.sleep(5)
        driver.find_element_by_xpath("//input[@class='nui-ipt-input' and \
                                    @type='text']").send_keys(Keys.ENTER)

        #断言搜索邮件标签页面
        time.sleep(5)
        text = driver.find_element_by_xpath("//div[@id='dvMultiTab']/ul\
                                            /li[8]/div[3]").text
        time.sleep(3)
        self.assertEqual(text, u'搜索邮件')

        print u"准备退出..."
        login.logout(self)
        print u"退出了..."
Exemple #2
0
    def test_login(self):
        u'''登录名和密码正确时正确登录(登录名为tzjjd527)'''
        driver = self.driver
        driver.get(self.base_url)
        driver.implicitly_wait(30)

        login.login(self, "tzjjd527", "tmjd527527")
        text = driver.find_element_by_id("spnUid").text
        self.assertEqual(text, u"*****@*****.**")
        driver.implicitly_wait(3000)
        login.logout(self)
Exemple #3
0
    def test_wifiadmin_ad_chk(self):
        u'''成功审核广告'''
        #获取当前时间
        now = time.strftime("%Y-%m-%d %H-%M-%S")

        #webdriver驱动
        driver = self.driver
        driver.maximize_window()  #窗口最大化

        #登录百万点系统
        login.login(driver, self.baseurl, 'test', 'testing')

        #点击广告
        driver.find_element_by_css_selector(
            ".ku_fix.quike").find_element_by_xpath("h1[2]").click()

        #点击广告&广告位
        driver.find_element_by_css_selector("h2[accessid='11']").click()

        #点击广告审核
        driver.find_element_by_css_selector("li[accessid='33']").click()

        try:
            #审核通过一条广告,点击审核按钮
            ad_driver_list = driver.find_elements_by_css_selector(
                ".b_table>tbody>tr")
            ad_driver_list[4].find_element_by_css_selector(
                "button[class='one']").click()

            #选择审核通过
            time.sleep(1)
            driver.find_elements_by_css_selector(
                "input[name='audit_status']")[0].click()

            #输入审核说明
            driver.find_element_by_css_selector("#audit_desc").send_keys(
                u"测试testing")

            #点击提交按钮
            driver.find_element_by_css_selector("#ad_audit_btn").click()

            self.assertEqual(
                u"广告审核成功!",
                driver.find_element_by_css_selector(
                    ".ajax_build_tip.success").text)
        except Exception as e:
            print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e))
            screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_ad_chk_errorimg" + now + ".jpg"  #错误截图存放路径
            driver.get_screenshot_as_file(screenshot_path)  #错误截屏

        finally:
            #退出百万点系统
            time.sleep(1)
            login.logout(driver)
Exemple #4
0
	def test_right(self):
		u'''登录成功'''
		driver = self.driver
		driver.get(self.base_url)
		tagname = root.getElementsByTagName("right")
		username = tagname[0].getAttribute("username")
		password = tagname[0].getAttribute("password")
		prompt_info = tagname[0].firstChild.data
		login.login(self,username,password)
		text = driver.find_element_by_xpath("//div[@class='info clearfix']/a/em").text
		self.assertEqual(text,prompt_info)
		login.logout(self)
Exemple #5
0
    def test_send_mail3(self):
        driver = self.driver
        driver.get(self.base_url)

        #登录
        login.login(self)

        driver.switch_to_default_content()
        #写信
        #driver.find_element_by_css_selector("#_mail_component_47_47 > span.oz0").click()
        time.sleep(10)
        driver.find_element_by_css_selector("#_mail_component_70_70 >\
                                            span.oz0").click()
        time.sleep(10)
        #填写收件人和主题
        driver.find_element_by_xpath("//*[@class='bz0']/div[2]/div[1]/input")\
            .send_keys(self.username + '@126.com;')
        time.sleep(5)
        driver.find_element_by_xpath("//input[@class='nui-ipt-input'\
                                     and @type='text'\
                                     and @maxlength='256']"                                                           ).\
            send_keys(u'给iht的信')
        time.sleep(10)

        #上传附件
        print u"准备上传附件"
        #driver.find_element_by_class_name("O0").send_keys(
        #    r'C:\Python27\python.exe')

        driver.find_element_by_class_name("by0").click()
        time.sleep(2)

        # SendKeys
        SendKeys.SendKeys(r'C:\Python27\python.exe')  # 发送文件地址
        time.sleep(2)
        SendKeys.SendKeys("{ENTER}")  # 发送回车键

        print u"准备发送邮件"

        #发送邮件
        time.sleep(10)
        driver.find_element_by_xpath("/html/body/div[2]/div[1]/div[2]\
                                     /header/div[1]/div[1]/div[1]\
                                     /span[2]").click()

        #断言发送结果
        time.sleep(10)
        text = driver.find_element_by_class_name('tK1').text
        self.assertEqual(text, u'发送成功可用手机接收回复')
        print u"准备退出..."
        login.logout(self)
        print u"退出了..."
Exemple #6
0
 def test_163mail_login_logout(self):
     u'''正常登陆和退出'''
     username = self.xlseng.readcell('sheet1',2,2)
     password = self.xlseng.readcell('sheet1',2,3)
     exp_info_login = self.xlseng.readcell('sheet1',2,4)
     exp_info_logout = self.xlseng.readcell('sheet1',2,5)
     
     driver = self.driver
     login.login(driver,self.base_url,username,password)
     self.assertEqual(exp_info_login, driver.find_element_by_id("spnUid").text)
     
     login.logout(driver)
     self.assertEqual(exp_info_logout, driver.find_element_by_css_selector("h1").text)
Exemple #7
0
 def test_search_mail(self):
     driver = self.driver
     driver.get(self.base_url)
     #调用登录模块
     login.login(self,'*****@*****.**','zwb888888')
     #搜索邮件
     driver.find_element_by_xpath("//input[@class='nui-ipt-input' and @type='text']").send_keys(u'小明')
     driver.find_element_by_xpath("//input[@class='nui-ipt-input' and @type='text']").send_keys(Keys.ENTER)
     #断言搜索邮件标签页面
     text= driver.find_element_by_xpath("//div[@id='dvMultiTab']/ul/li[5]/div[3]").text
     self.assertEqual(text,u'搜索邮件')
     #调用退出
     login.logout(self)
 def test_login3(self):
     '''不输入用户名登录测试'''
     driver = self.driver
     driver.get(self.url)
     time.sleep(2)
     driver.switch_to.frame(0)
     #无用户名和密码
     login.login(self, "test616387", "")
     # 获取断言信息进行验证
     test = login.trylogin(self)
     self.assertTrue(test)
     # 退出操作
     login.logout(self)
 def test_wifiadmin_login_logout(self):
     u'''正常登陆和退出'''
     username = self.xlseng.readcell('sheet1',2,2)
     password = self.xlseng.readcell('sheet1',2,3)
     exp_info_login = self.xlseng.readcell('sheet1',2,4)
     exp_info_logout = self.xlseng.readcell('sheet1',2,5)
     
     driver = self.driver
     login.login(driver,self.base_url,username,password)
     self.assertEqual(exp_info_login, driver.find_element_by_css_selector("div.hi>h1").text)
     
     time.sleep(2)
     login.logout(driver)
     self.assertEqual(exp_info_logout, driver.current_url)
    def test_login(self):
        '''登录邮箱成功测试'''
        driver = self.driver
        driver.get(self.url)
        time.sleep(2)
        driver.switch_to.frame(0)
        #登录126邮箱
        login.login(self, "test616387", "a123456")
        #获取断言信息进行验证
        test = login.trylogin(self)
        self.assertTrue(test)

        #退出操作
        login.logout(self)
    def test_send_mail4(self):
        driver = self.driver
        driver.get(self.base_url)
        #登录
        login.login(self,"*****@*****.**","zwb888888")
        #写信
        driver.find_element_by_xpath(".//*[@id='_mail_component_57_57']/span[2]").click()
        #填写收件人和主题
        driver.find_element_by_xpath("//*[@class='bz0']/div[2]/div/input").send_keys('*****@*****.**')
        time.sleep(2)
        #driver.find_element_by_xpath(".//*[@id='_mail_button_13_253']/span[2]").click()
        driver.find_element_by_xpath("//input[@class='nui-ipt-input' and @type='text' and @maxlength='256']").send_keys(u'给小明的信')
        
        #获得当前窗口的句柄
        window_handle = driver.window_handles
        
        #定位富文本表单
        print window_handle
        class_name = driver.find_element_by_class_name('APP-editor-iframe')
        driver.switch_to_frame(class_name)
        #编写邮件正文
        driver.find_element_by_tag_name('body').send_keys(u'你好,小明好久不见。')
        #退出iframe
        driver.switch_to_default_content()
        #driver.switch_to_window(window_handle)
        #断言发送结果
        #driver.find_element_by_xpath("//*[@id='_mail_button_11_237']/span[2]").click()
        
        driver.find_element_by_xpath("//header/div/div/div/span[2]").click()

        #需要一个加一个智能等待时间
        #time.sleep(2)
        #隐式等待
        #driver.implicitly_wait(6)
        
        #智能等待
        showelement=driver.find_element_by_class_name('tK1')
        
        element = WebDriverWait(driver,10,0.5).until(lambda driver : showelement.is_displayed())
     
        
        text = driver.find_element_by_class_name('tK1').text
        
        print text

        #断言验证
        self.assertEqual(text,u'发送成功免费短信通知')

        #退出
        login.logout(self)
Exemple #12
0
    def test_reg(self):
        u"""iwebshop注册测试用例"""
        print u'test_reg开始执行'
        driver = self.driver
        wb = xlrd.open_workbook('C:\python\data\data.xls')
        sh = wb.sheet_by_name('reg')
        rows = sh.nrows
        for i in range(2, rows):
            email = sh.cell_value(i, 0)
            username = sh.cell_value(i, 1)
            password = sh.cell_value(i, 2)
            repwd = sh.cell_value(i, 3)
            driver.get("http://127.0.0.1:8888/iwebshop/")
            driver.implicitly_wait(8)
            time.sleep(1)
            #点击注册
            driver.find_element_by_link_text(u"免费注册").click()
            driver.find_element_by_name("email").send_keys(email)
            driver.find_element_by_name("username").clear()
            driver.find_element_by_name("username").send_keys(username)
            driver.find_element_by_name("password").clear()
            driver.find_element_by_name("password").send_keys(password)
            driver.find_element_by_name("repassword").clear()
            driver.find_element_by_name("repassword").send_keys(repwd)
            driver.find_element_by_xpath(
                u"//input[@value='同意一下条款,提交']").click()

            #获取预期结果
            a = driver.find_element_by_xpath(
                "//td/p[2]/span[@class='orange bold']").text
            print u'实际结果:', a
            #预期结果
            b = username
            print u'实际结果:', b
            #比对实际结果与预期结果
            try:
                #使用assertIn函数判断username是否在预期结果里面
                self.assertIn(username, a, msg='register failed!')
                print u'测试通过'
            except AssertionError, msg:
                #错误截图函数
                driver.get_screenshot_as_file('c:\python\error\reg_error.png')
                print msg
                print u'测试失败'

            time.sleep(1)
            #调用退出函数
            login.logout(self)
Exemple #13
0
    def test_send_emails(self):
        driver = self.driver
        driver.get(self.base_url)
        #登录
        login.login(self,"tzjjd527","tmjd527527")
        #写信
        driver.find_element_by_css_selector(".nui-ico.fn-bg.ga0").click()
        #收件人
        driver.find_element_by_css_selector(".nui-editableAddr-ipt").send_keys("*****@*****.**")

        #发送还是有问题meme
        driver.find_element_by_xpath("/html/body/div[2]/div/div[2]/header/div/div/div/span[2]").click()
        driver.find_element_by_xpath("//*[@class='nui-msgbox-ft-btns']/div/span").click()
        text = driver.find_element_by_class_name('tK1').text
        self.assertEqual(text,u'发送成功')
        login.logout(self)
Exemple #14
0
 def test_login(self):
     driver = self.driver
     driver.get(self.base_url)
     login.login(self, "yulb1994", "zxcvylb1994")
     # driver.switch_to_frame("x-U RS-iframe")
     # driver.find_element_by_xpath('//*[@name="email"]').clear()
     # driver.find_element_by_xpath('//*[@name="email"]').send_keys('yulb1994')
     # driver.find_element_by_xpath('//*[@name="password"]').clear()
     # driver.find_element_by_xpath('//*[@name="password"]').send_keys("zxcvylb1994")
     # driver.find_element_by_id("dologin").click()
     # 获取断言信息进行断言
     text = driver.find_element_by_id('spnUid').text
     self.assertEqual("*****@*****.**", text)
     # 退出
     login.logout(self)
     time.sleep(2)
 def test_login(self):
     u"""用户登录"""
     driver = self.driver
     we = self.we
     driver.get(self.base_url)
     #login.login(self)  #登录
     
     try:
         login.login(self)  #登录
         
     except:
         browser.get_screenshot_as_file("E:\\selenium_test_case\\error\\loginError.png")
         raise NameError('login error!')
     
     
     login.logout(self)  #退出
Exemple #16
0
    def test_send_mail(self):
        driver = self.driver
        driver.get(self.base_url)
        self.driver.implicitly_wait(30)

        #logins = root.getElementsByTagName('user_pawd')
        #获得user_pawd 标签的username、passwrod 属性值
        #username=logins[0].getAttribute("username")
        #password=logins[0].getAttribute("password")
        #prompt_info = logins[0].firstChild.data

        #登录
        login.login(self)
        #login.login(self,username,password)
        #login.login(self,"testingwtb","a123456")
        driver.switch_to_default_content()
        #写信
        time.sleep(10)
        driver.find_element_by_css_selector(
            "#_mail_component_70_70 > span.oz0").click()
        time.sleep(10)
        #填写收件人
        driver.find_element_by_xpath("//*[@class='bz0']/div[2]/\
                                     div[1]/input"                                                  ).\
            send_keys(self.username + '@126.com;')
        #driver.find_element_by_id("//*[@class='bz0']/div[2]/div/input").send_keys(Keys.ENTER)
        #html/body/div[7]/table/tbody/tr/td/span/strong[1]
        #html/body/div[7]/table/tbody/tr/td/span/strong[1]
        #发送邮件
        time.sleep(10)
        driver.find_element_by_xpath("/html/body/div[2]/div[1]/div[2]\
                                     /header/div[1]/div[1]/div[1]\
                                     /span[2]").click()
        #driver.find_element_by_xpath("//*[@id='_mail_button_2_182']/span[2]").click()
        #driver.find_element_by_xpath("//*[@id='_mail_button_9_208']/span[2]").click()
        #driver.find_element_by_xpath("//span[contains(text(),'发送') and @class='nui-btn-text']").click()
        time.sleep(10)
        driver.find_element_by_xpath(
            "//*[@class='nui-msgbox-ft-btns']/div/span").click()
        #断言发送结果
        time.sleep(10)
        text = driver.find_element_by_class_name('tK1').text
        self.assertEqual(text, u'发送成功可用手机接收回复')
        print u"准备退出..."
        login.logout(self)
        print u"退出了..."
    def test_wifiadmin_addelivery_chk(self):
        u"审核广告投放"
        #获取当前时间
        now = time.strftime("%Y-%m-%d %H-%M-%S")

        #webdriver驱动
        driver = self.driver
        driver.maximize_window()  #窗口最大化

        #登录百万点系统
        login.login(driver, self.baseurl, 'test', 'testing')

        #点击广告
        driver.find_element_by_css_selector(".ku_fix.quike").find_element_by_xpath("h1[2]").click()

        #点击广告投放
        driver.find_element_by_css_selector("h2[accessid='10']").click()

        #点击投放审核
        driver.find_element_by_css_selector("li[accessid='29']").click()

        try:
            #审核通过一条广告,点击审核按钮
            addelivery_driver_list = driver.find_elements_by_css_selector(".b_table>tbody>tr")
            addelivery_driver_list[0].find_element_by_css_selector("button[class='one']").click()

            #选择审核通过
            time.sleep(1)
            driver.find_elements_by_css_selector("input[name='audit_status']")[0].click()

            #输入审核说明
            driver.find_element_by_css_selector("#audit_remark").send_keys(u"测试testing")

            #点击提交按钮
            driver.find_element_by_css_selector(".fsub").find_element_by_css_selector("button[type='submit']").click()

            self.assertEqual(u"广告投放审核成功", driver.find_element_by_css_selector(".ajax_build_tip.success").text)
        except Exception as e:
            print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e))
            screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_addelivery_chk_errorimg" + now + ".jpg" #错误截图存放路径
            driver.get_screenshot_as_file(screenshot_path)   #错误截屏

        finally:
            #退出百万点系统
            time.sleep(1)
            login.logout(driver)
Exemple #18
0
    def test_send_mail4(self):
        driver = self.driver
        driver.get(self.base_url)

        #登录
        login.login(self)

        driver.switch_to_default_content()
        #写信
        time.sleep(10)
        driver.find_element_by_css_selector("#_mail_component_70_70 >\
                                            span.oz0").click()
        time.sleep(10)
        #填写收件人和主题
        driver.find_element_by_xpath("//*[@class='bz0']/div[2]/div[1]/input")\
            .send_keys(self.username + '@126.com;')
        time.sleep(5)
        driver.find_element_by_xpath("//input[@class='nui-ipt-input'\
                                     and @type='text'\
                                     and @maxlength='256']"                                                           ).\
            send_keys(u'给iht的信')
        time.sleep(10)

        #定位富文本表单
        class_name = driver.find_element_by_class_name('APP-editor-iframe')
        driver.switch_to_frame(class_name)
        #编写邮件正文
        driver.find_element_by_tag_name('body').send_keys(u'你好,\
                                                          小明好久不见。')

        time.sleep(10)
        print u"准备发送邮件"
        #发送邮件
        driver.switch_to_default_content()
        time.sleep(3)
        driver.find_element_by_xpath("/html/body/div[2]/div[1]/div[2]\
                                     /header/div[1]/div[1]/div[1]\
                                     /span[2]").click()

        time.sleep(10)
        #断言发送结果
        text = driver.find_element_by_class_name('tK1').text
        self.assertEqual(text, u'发送成功可用手机接收回复')
        print u"准备退出..."
        login.logout(self)
        print u"退出了..."
Exemple #19
0
 def test_send_mail(self):
     driver=self.driver
     driver.get(self.base_url)
     # 登录
     login.login(self,"yulb1994","zxcvylb1994")
     # 写信
     driver.find_element_by_xpath('//*[@class="js-component-component ra0 mD0"]').click()
     # 填写收件人
     driver.find_element_by_xpath('//*[@class="js-component-emailcontainer nui-multiLineIpt C-multiLineIpt nui-ipt"]').clear()
     driver.find_element_by_xpath('//*[@class="js-component-emailcontainer nui-multiLineIpt C-multiLineIpt nui-ipt"]').send_keys("*****@*****.**")
     # 发送邮件
     driver.find_element_by_xpath('//*[@class="nui-btn-icon"]/span[1]').click()
     driver.find_element_by_xpath('//*[@class="nui-btn-text"]/span').click()
     # 断言发送结果
     text=driver.find_element_by_xpath('//*[@class="nui-ico se0 pv1"]/b').text
     self.assertEqual(text,u'发送成功')
     time.sleep(5)
     login.logout(self)
Exemple #20
0
    def test_del_mail1(self):
        driver = self.driver
        driver.get(self.base_url)
        #self.driver.implicitly_wait(30)

        #登录
        login.login(self)

        driver.switch_to_default_content()
        time.sleep(5)
        driver.find_element_by_class_name('nui-tree-item-text').click()
        #driver.find_element_by_class_name(\
        #    'nui-tabs-item-text nui-fNoSelect').click()
        #driver.find_element_by_xpath("//span[@calss='nui-tree-item-text' and \
        #                            @title=u'收件箱']").click()
        print u"点击了收件箱"
        time.sleep(5)

        driver.find_elements_by_xpath("//span[@class='nui-chk-symbol']\
                                    /b").pop(1).click()
        time.sleep(3)
        try:
            spans = driver.find_elements_by_tag_name('span')
            for s in spans:
                #print s.text
                if s.text == u'删 除':
                    s.click()
                    print u"点击删除"
                    break
        except:
            #print u"没找到删除键"
            pass

        #断言是否已删除
        time.sleep(5)
        text = driver.find_element_by_css_selector(\
            "span.nui-tips-text > a").text
        self.assertEqual(text, u'已删除')
        #退出

        print u"准备退出..."
        login.logout(self)
        print u"退出了..."
Exemple #21
0
    def test_wifiadmin_addelivery_del(self):
        u"删除广告投放"
        #获取当前时间
        now = time.strftime("%Y-%m-%d %H-%M-%S")

        #webdriver驱动
        driver = self.driver
        driver.maximize_window()  #窗口最大化

        #登录百万点系统
        login.login(driver, self.baseurl, 'test', 'testing')

        #点击广告
        driver.find_element_by_css_selector(".ku_fix.quike").find_element_by_xpath("h1[2]").click()

        #点击广告投放
        driver.find_element_by_css_selector("h2[accessid='10']").click()

        #点击投放管理
        driver.find_element_by_css_selector("li[accessid='27']").click()

        try:
            #勾选一条广告投放  默认第一条被勾选
            #addelivery_driver_list = driver.find_elements_by_css_selector(".b_table>tbody>tr")
            #addelivery_driver_list[0].find_element_by_css_selector(".checkbox").click()

            #点击删除按钮
            driver.find_element_by_css_selector(".del").click()

            #弹窗确定
            driver.switch_to_alert().accept()

            self.assertEqual(u"投放广告删除成功!", driver.find_element_by_css_selector(".ajax_build_tip").text)

        except Exception as e:
            print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e))
            screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_addelivery_del_errorimg" + now + ".jpg" #错误截图存放路径
            driver.get_screenshot_as_file(screenshot_path)   #错误截屏

        finally:
            #退出百万点系统
            time.sleep(1)
            login.logout(driver)
Exemple #22
0
    def test_wifiadmin_ad_del(self):
        u'''删除广告'''
        #获取当前时间
        now = time.strftime("%Y-%m-%d %H-%M-%S")

        #webdriver驱动
        driver = self.driver
        driver.maximize_window()  #窗口最大化

        #登录百万点系统
        login.login(driver, self.baseurl, 'test', 'testing')

        #点击广告
        driver.find_element_by_css_selector(
            ".ku_fix.quike").find_element_by_xpath("h1[2]").click()

        #点击广告&广告位
        driver.find_element_by_css_selector("h2[accessid='11']").click()

        #点击广告基本信息
        driver.find_element_by_css_selector("li[accessid='32']").click()

        try:
            #删除一条广告
            ad_driver_list = driver.find_elements_by_css_selector(
                ".b_table>tbody>tr")
            ad_driver_list[4].find_element_by_css_selector(
                "button[class='more']").click()
            ad_driver_list[4].find_element_by_css_selector(
                "dl[class='maction']").click()
            driver.switch_to_alert().accept()

            self.assertEqual(
                u"删除成功!",
                driver.find_element_by_css_selector(".ajax_build_tip").text)
        except Exception as e:
            print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e))
            screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_ad_del_errorimg" + now + ".jpg"  #错误截图存放路径
            driver.get_screenshot_as_file(screenshot_path)  #错误截屏
        finally:
            #退出百万点系统
            time.sleep(1)
            login.logout(driver)
Exemple #23
0
    def test_send_mail2(self):
        driver = self.driver
        driver.get(self.base_url)
        #登录
        login.login(self)
        #login.login(self,"testingwtb","a123456")
        driver.switch_to_default_content()
        #写信
        #driver.find_element_by_css_selector("#_mail_component_47_47 > span.oz0").click()
        time.sleep(10)
        driver.find_element_by_css_selector("#_mail_component_70_70 > span.oz0").\
                                                                    click()
        time.sleep(10)
        #填写收件人和主题
        driver.find_element_by_xpath("//*[@class='bz0']/div[2]/div[1]/input")\
            .send_keys(self.username + '@126.com;')

        #填写收件人和主题
        #driver.find_element_by_xpath("//*[@class='bz0']/div[2]
        #                /div/input").send_keys('*****@*****.**')
        #driver.find_element_by_xpath("//input[@class='nui-ipt-input' and
        #                            @type='text' and @maxlength='256']").\
        #    send_keys(u'给小明的信')
        driver.find_element_by_xpath("//input[@class='nui-ipt-input'\
                                     and @type='text'\
                                     and @maxlength='256']"                                                           ).\
            send_keys(u'给iht的信')
        #发送邮件
        time.sleep(10)
        driver.find_element_by_xpath("/html/body/div[2]/div[1]/div[2]\
                                     /header/div[1]/div[1]/div[1]\
                                     /span[2]").click()

        #driver.find_element_by_xpath("/html/body/div[2]/div/div[2]/header
        #/div/div/div/span[2]").click()
        #断言发送结果
        time.sleep(10)
        text = driver.find_element_by_class_name('tK1').text
        self.assertEqual(text, u'发送成功可用手机接收回复')
        print u"准备退出..."
        login.logout(self)
        print u"退出了..."
Exemple #24
0
 def test_login(self):
     u'''用户名、密码正确'''
     driver = self.driver
     driver.get(self.base_url)
     self.driver.implicitly_wait(10)
     logins = root.getElementsByTagName('user_pawd')
     # 获得null 标签的username、passwrod 属性值
     username = logins[0].getAttribute("username")
     password = logins[0].getAttribute("password")
     prompt_info = logins[0].firstChild.data
     #调用登录函数
     print "登录iCloudUinon"
     login.login(self, username, password)
     time.sleep(2)
     title = driver.title
     print title
     self.assertEqual(title, u"iCloudUnion")
     # 调用退出函数
     print "登出iCloudUinon"
     login.logout(self)
 def test_send_email(self):
     '''发送邮件测试'''
     driver = self.driver
     driver.maximize_window()
     driver.get(self.url)
     time.sleep(2)
     driver.switch_to.frame(0)
     login.login(self,"test616387","a123456")
     login.trylogin(self)
     driver.find_element_by_xpath('''//*[@id="_mail_component_70_70"]/span[2]''').click()
     time.sleep(1)
     driver.find_element_by_class_name("nui-editableAddr-ipt").send_keys("*****@*****.**")
     time.sleep(2)
     name = driver.find_element_by_class_name("APP-editor-iframe")
     driver.switch_to.frame(name)
     driver.find_element_by_xpath("/html/body").send_keys(u"小明你好!")
     driver.switch_to.default_content()
     driver.find_element_by_class_name("nui-btn-text").click()
     time.sleep(1)
     text = driver.find_element_by_xpath('''//*[@id="1508469869086_succInfo"]''').text
     self.assertEqual(text,u"发送成功")
     login.logout()
Exemple #26
0
 def test_wifiadmin_ad_del(self):
     u'''删除广告'''
     #获取当前时间
     now = time.strftime("%Y-%m-%d %H-%M-%S")
         
     #webdriver驱动
     driver = self.driver
     driver.maximize_window()  #窗口最大化
     
     #登录百万点系统
     login.login(driver, self.baseurl, 'test', 'testing')
     
     #点击广告
     driver.find_element_by_css_selector(".ku_fix.quike").find_element_by_xpath("h1[2]").click()
     
     #点击广告&广告位
     driver.find_element_by_css_selector("h2[accessid='11']").click()
     
     #点击广告基本信息
     driver.find_element_by_css_selector("li[accessid='32']").click()
     
     try:
         #删除一条广告
         ad_driver_list = driver.find_elements_by_css_selector(".b_table>tbody>tr")
         ad_driver_list[4].find_element_by_css_selector("button[class='more']").click()
         ad_driver_list[4].find_element_by_css_selector("dl[class='maction']").click()
         driver.switch_to_alert().accept()
     
         self.assertEqual(u"删除成功!", driver.find_element_by_css_selector(".ajax_build_tip").text)
     except Exception as e:
         print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e))
         screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_ad_del_errorimg" + now + ".jpg" #错误截图存放路径
         driver.get_screenshot_as_file(screenshot_path)   #错误截屏
     finally:     
         #退出百万点系统
         time.sleep(1)
         login.logout(driver)    
Exemple #27
0
    def test_login_ok(self):
        u"""iwebshop登录有效测试用例"""
        print u'test_login_ok 开始执行'
        driver = self.driver
        wb = xlrd.open_workbook('C:\python\data\data.xls')
        sh = wb.sheet_by_name('logok')
        rows = sh.nrows
        for i in range(1,rows):
            username = sh.cell_value(i,0)
            password = sh.cell_value(i,1)
            #访问网址
            driver.get("http://127.0.0.1:8888/iwebshop/")
            
            #调用登录函数
            login.login(self,username,password)

            #获取错误提示信息
            a=driver.find_element_by_class_name("loginfo").text

            #print repr(text)
            #a= text.encode('gb2312')

            #print '实际结果:',a
            b=username+u"您好,欢迎您来到iwebshop购物![安全退出]"
            #print '预期结果:',b
            c=cmp(a,b)
            if c==0:
                print "success"
                print u'测试通过'
            else:
                print "fail"
                #print u'测试失败'


            #调用退出函数
            login.logout(self)
Exemple #28
0
    def test_wifiadmin_ad_modify(self):
        u'''修改广告'''
        #获取当前时间
        now = time.strftime("%Y-%m-%d %H-%M-%S")
        chuo_now = time.time()
            
        #webdriver驱动
        driver = self.driver
        driver.maximize_window()  #窗口最大化
        
        #登录百万点系统
        login.login(driver, self.baseurl, 'test', 'testing')
        
        #点击广告
        driver.find_element_by_css_selector(".ku_fix.quike").find_element_by_xpath("h1[2]").click()
        
        #点击广告&广告位
        driver.find_element_by_css_selector("h2[accessid='11']").click()
        
        #点击广告基本信息
        driver.find_element_by_css_selector("li[accessid='32']").click()
        
        #修改一条广告
        ad_driver_list = driver.find_elements_by_css_selector(".b_table>tbody>tr")
        ad_driver_list[4].find_element_by_css_selector("button[onclick]").click()
        
        #输入广告名称
        ad_name_dr = driver.find_element_by_css_selector("#ad_name")
        ad_name_new = "testadname" + str(chuo_now)
        ad_name_dr.clear()
        ad_name_dr.send_keys(ad_name_new)
    
        #输入广告分类
        driver.find_element_by_css_selector("#ad_cate_id").click()
        driver.find_element_by_css_selector("#ad_cate_id").find_elements_by_tag_name("option")[7].click()
        
        #输入所属广告主
        driver.find_element_by_id("source_id").click()
        driver.find_element_by_id("source_id").find_elements_by_tag_name("option")[2].click()
        
        #文件上传
        driver.find_element_by_id("ad_up_file").click()
        os.system(r"E:\Code\yzhselenium\test_wifiadmin\testcase\tools\upfile.exe") 

        #输入目标网址
        driver.find_element_by_id("ad_link").send_keys("http://m.100msh.com")  
        
        #输入广告描述
        driver.find_element_by_id("ad_desc").send_keys("test ad modiy discription")
         
        try:
            #点击保存按钮
            driver.find_element_by_css_selector(".fsub>button").click()
        
            self.assertEqual(u"广告修改成功!", driver.find_element_by_css_selector(".ajax_build_tip").text)
        except Exception as e:
            print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e))
            screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_ad_modify_errorimg" + now + ".jpg" #错误截图存放路径
            driver.get_screenshot_as_file(screenshot_path)   #错误截屏
        finally:     
            #退出百万点系统
            time.sleep(1)
            login.logout(driver)
Exemple #29
0
    def test_wifiadmin_ad_add(self):
        u'''添加广告'''
        #读取数据
        adname_list = self.xlseng.readcol('sheet2', 2)  #广告名称
        adtype_list = self.xlseng.readcol('sheet2', 3)  #广告分类
        admaster_list = self.xlseng.readcol('sheet2', 4)  #所属广告主
        adwname_list = self.xlseng.readcol('sheet2', 5)  #广告位名称
        #adpicturepath_list = self.xlseng.readcol('sheet2',6)  #上传文件路径
        adtip_list = self.xlseng.readcol('sheet2', 7)  #提示信息
        adnetaddress_list = self.xlseng.readcol('sheet2', 8)  #目标网址
        adopenmodel_list = self.xlseng.readcol('sheet2', 9)  #打开模式
        addefault_list = self.xlseng.readcol('sheet2', 10)  #默认广告
        addescription_list = self.xlseng.readcol('sheet2', 11)  #广告描述
        adpartnername_list = self.xlseng.readcol('sheet2', 12)  #商户名称
        addefaultcity_list = self.xlseng.readcol('sheet2', 13)  #默认广告地区
        exception_result_list = self.xlseng.readcol('sheet2', 14)  #预期结果

        #nrow = self.xlseng.readcol('sheet2',1)[-1] #数据总行数,不括含首行
        nrow = self.xlseng.info('sheet2')[0]  #数据总行数,包括首行
        print "nrow: %d" % nrow

        #webdriver驱动
        driver = self.driver
        driver.maximize_window()  #窗口最大化

        i = 1
        while i < nrow:
            #获取当前时间
            now = time.strftime("%Y-%m-%d %H-%M-%S")

            #登录百万点系统
            login.login(driver, self.baseurl, 'test', 'testing')

            #点击广告
            driver.find_element_by_css_selector(
                ".ku_fix.quike").find_element_by_xpath("h1[2]").click()

            #点击广告&广告位
            driver.find_element_by_css_selector("h2[accessid='11']").click()

            #点击广告基本信息
            driver.find_element_by_css_selector("li[accessid='32']").click()

            #点击“+”号
            driver.find_element_by_css_selector(".add").click()

            #输入广告添加所需的各字段信息
            #输入广告名称
            driver.find_element_by_css_selector("#ad_name").send_keys(
                adname_list[i])

            #广告分类下拉选择
            if adtype_list[i]:
                adtype_select = {
                    u"商户广告": 1,
                    u"商业广告": 2,
                    u"宣传广告": 3,
                    u"友情合作广告": 4,
                    u"内测广告": 5,
                    u"WIFI认证": 6,
                    u"外测广告": 7,
                    u"宏创广告": 8
                }
                driver.find_element_by_css_selector("#ad_cate_id").click()
                menu_select = driver.find_element_by_css_selector(
                    "#ad_cate_id").find_elements_by_tag_name("option")
                nselect = adtype_select[adtype_list[i]]
                menu_select[nselect].click()

                if u"商户广告" == adtype_list[i]:
                    if adpartnername_list[i]:
                        #搜索商户名称
                        driver.find_element_by_name(
                            "partner_search_key").send_keys(
                                adpartnername_list[i])
                        driver.find_element_by_css_selector(
                            "#partner_search").click()
                        if driver.find_element_by_css_selector(
                                ".partner_search_list>ul>li").is_enabled():
                            driver.find_element_by_css_selector(
                                ".partner_search_list>ul>li").click()
                        else:
                            print u"未搜索到商户"

            #所属广告主下拉选择
            if admaster_list[i]:
                admaster_select = {u"百米生活": 1, u"都江堰": 2}
                driver.find_element_by_id("source_id").click()
                menu_select = driver.find_element_by_id(
                    "source_id").find_elements_by_tag_name("option")
                nselect = admaster_select[admaster_list[i]]
                menu_select[nselect].click()

            #广告位名称下拉选择
            if adwname_list[i]:
                adwname_select = {u"如影随形": 1, u"读秒广告": 2}
                driver.find_element_by_id("group_id").click()
                menu_select = driver.find_element_by_id(
                    "group_id").find_elements_by_tag_name("option")
                nselect = adwname_select[adwname_list[i]]
                menu_select[nselect].click()

                #文件上传
                driver.find_element_by_id("ad_up_file").click()
                #调用autoit脚本
                os.system(
                    r"E:\Code\yzhselenium\test_wifiadmin\testcase\tools\upfile.exe"
                )

            #输入提示信息
            driver.find_element_by_id("ad_tips").send_keys(adtip_list[i])

            #输入目标网址
            driver.find_element_by_id("ad_link").send_keys(
                adnetaddress_list[i])

            #选择打开模式
            adopenmodel_select = {u"新窗口打开": 0, u"本窗口打开": 1}
            radio_select = driver.find_elements_by_name("ad_open_mode")
            nselect = adopenmodel_select[adopenmodel_list[i]]
            radio_select[nselect].click()

            #选择默认广告
            addefault_select = {u"否": 0, u"是": 1}
            radio_select = driver.find_elements_by_name("is_default")
            addefault_nselect = addefault_select[addefault_list[i]]
            radio_select[addefault_nselect].click()
            #选择默认广告地区
            if 1 == addefault_nselect:
                city_list = {
                    u"全国": 0,
                    u"北京": 1,
                    u"天津": 2,
                    u"河北": 3,
                    u"山西": 4,
                    u"内蒙古": 5,
                    u"辽宁": 6,
                    u"吉林": 7,
                    u"黑龙江": 8,
                    u"上海": 9,
                    u"江苏": 10,
                    u"浙江": 11,
                    u"安徽": 12,
                    u"福建": 13,
                    u"江西": 14,
                    u"山东": 15,
                    u"河南": 16,
                    u"湖北": 17,
                    u"湖南": 18,
                    u"广东": 19,
                    u"广西": 20,
                    u"海南": 21,
                    u"重庆": 22,
                    u"四川": 23,
                    u"贵州": 24,
                    u"云南": 25,
                    u"西藏": 26,
                    u"陕西": 27,
                    u"甘肃": 28,
                    u"青海": 29,
                    u"宁夏": 30,
                    u"新疆": 31,
                    u"台湾": 32,
                    u"香港": 33,
                    u"澳门": 34
                }
                menu_select = driver.find_element_by_name(
                    "sc_id[]").find_elements_by_tag_name("option")
                nselect = city_list[addefaultcity_list[i]]
                menu_select[nselect].click()

            #输入广告描述
            driver.find_element_by_id("ad_desc").send_keys(
                addescription_list[i])

            try:
                #点击保存按钮
                driver.find_element_by_css_selector(".fsub>button").click()

                #接收弹窗
                if 1 == addefault_nselect:
                    driver.switch_to_alert().accept()

                #断言
                time.sleep(2)
                self.assertEqual(
                    exception_result_list[i],
                    driver.find_element_by_css_selector(
                        ".ajax_build_tip").text)
            except Exception as e:
                print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno,
                                              str(e))
                screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_ad_add_errorimg" + now + ".jpg"  #错误截图存放路径
                driver.get_screenshot_as_file(screenshot_path)  #错误截屏

            finally:
                if common_function.isElementPresent(driver, ".close"):
                    driver.find_element_by_css_selector(".close").click()

                #print u"退前"
                time.sleep(1)
                #退出百万点系统
                login.logout(driver)
                #print u"退后"
                #time.sleep(2)

            #循环变量自增
            i = i + 1
Exemple #30
0
 def test_nomal(self):
     u'正常登录'
     login.keyadd(self,'nomal')
     login.logout(self)
Exemple #31
0
    def test_wifiadmin_ad_add(self):
        u'''添加广告'''
        #读取数据
        adname_list = self.xlseng.readcol('sheet2',2)    #广告名称
        adtype_list = self.xlseng.readcol('sheet2',3)    #广告分类
        admaster_list = self.xlseng.readcol('sheet2',4)  #所属广告主
        adwname_list = self.xlseng.readcol('sheet2',5)   #广告位名称
        #adpicturepath_list = self.xlseng.readcol('sheet2',6)  #上传文件路径
        adtip_list = self.xlseng.readcol('sheet2',7)  #提示信息
        adnetaddress_list = self.xlseng.readcol('sheet2',8)   #目标网址
        adopenmodel_list = self.xlseng.readcol('sheet2',9)   #打开模式
        addefault_list = self.xlseng.readcol('sheet2',10)   #默认广告
        addescription_list = self.xlseng.readcol('sheet2',11)  #广告描述
        adpartnername_list = self.xlseng.readcol('sheet2',12)  #商户名称
        addefaultcity_list = self.xlseng.readcol('sheet2',13)  #默认广告地区
        exception_result_list = self.xlseng.readcol('sheet2',14)  #预期结果
        
        #nrow = self.xlseng.readcol('sheet2',1)[-1] #数据总行数,不括含首行
        nrow = self.xlseng.info('sheet2')[0]   #数据总行数,包括首行
        print "nrow: %d" %nrow
        
        #webdriver驱动
        driver = self.driver
        driver.maximize_window()  #窗口最大化
            
        i = 1
        while i < nrow:
            #获取当前时间
            now = time.strftime("%Y-%m-%d %H-%M-%S")
            
            #登录百万点系统
            login.login(driver, self.baseurl, 'test', 'testing')
        
            #点击广告
            driver.find_element_by_css_selector(".ku_fix.quike").find_element_by_xpath("h1[2]").click()
        
            #点击广告&广告位
            driver.find_element_by_css_selector("h2[accessid='11']").click()
        
            #点击广告基本信息
            driver.find_element_by_css_selector("li[accessid='32']").click()
        
            #点击“+”号
            driver.find_element_by_css_selector(".add").click()
        
            #输入广告添加所需的各字段信息
            #输入广告名称
            driver.find_element_by_css_selector("#ad_name").send_keys(adname_list[i])
            
            #广告分类下拉选择
            if adtype_list[i]:
                adtype_select = {u"商户广告":1, u"商业广告":2, u"宣传广告":3, u"友情合作广告":4, u"内测广告":5, u"WIFI认证":6, u"外测广告":7, u"宏创广告":8}
                driver.find_element_by_css_selector("#ad_cate_id").click()
                menu_select = driver.find_element_by_css_selector("#ad_cate_id").find_elements_by_tag_name("option")
                nselect = adtype_select[adtype_list[i]]
                menu_select[nselect].click()
            
                if u"商户广告" == adtype_list[i]:
                    if adpartnername_list[i]:
                        #搜索商户名称
                        driver.find_element_by_name("partner_search_key").send_keys(adpartnername_list[i])
                        driver.find_element_by_css_selector("#partner_search").click()
                        if driver.find_element_by_css_selector(".partner_search_list>ul>li").is_enabled():
                            driver.find_element_by_css_selector(".partner_search_list>ul>li").click()
                        else:
                            print u"未搜索到商户"
            
            #所属广告主下拉选择
            if admaster_list[i]:
                admaster_select = {u"百米生活":1, u"都江堰":2}
                driver.find_element_by_id("source_id").click()
                menu_select = driver.find_element_by_id("source_id").find_elements_by_tag_name("option")
                nselect = admaster_select[admaster_list[i]]
                menu_select[nselect].click()

            #广告位名称下拉选择
            if adwname_list[i]:
                adwname_select = {u"如影随形":1, u"读秒广告":2}
                driver.find_element_by_id("group_id").click()
                menu_select = driver.find_element_by_id("group_id").find_elements_by_tag_name("option")
                nselect = adwname_select[adwname_list[i]]
                menu_select[nselect].click()
            
                #文件上传
                driver.find_element_by_id("ad_up_file").click()
                #调用autoit脚本
                os.system(r"E:\Code\yzhselenium\test_wifiadmin\testcase\tools\upfile.exe")
            
            #输入提示信息
            driver.find_element_by_id("ad_tips").send_keys(adtip_list[i])
            
            #输入目标网址
            driver.find_element_by_id("ad_link").send_keys(adnetaddress_list[i])
            
            #选择打开模式
            adopenmodel_select = {u"新窗口打开":0, u"本窗口打开":1}
            radio_select = driver.find_elements_by_name("ad_open_mode")
            nselect = adopenmodel_select[adopenmodel_list[i]]
            radio_select[nselect].click()
            
            #选择默认广告
            addefault_select = {u"否":0, u"是":1}
            radio_select = driver.find_elements_by_name("is_default")
            addefault_nselect = addefault_select[addefault_list[i]]
            radio_select[addefault_nselect].click()
            #选择默认广告地区
            if 1 == addefault_nselect:
                city_list = {u"全国":0, u"北京":1, u"天津":2, u"河北":3, u"山西":4, u"内蒙古":5, u"辽宁":6, u"吉林":7, u"黑龙江":8, u"上海":9, u"江苏":10, 
                             u"浙江":11, u"安徽":12, u"福建":13, u"江西":14, u"山东":15, u"河南":16, u"湖北":17, u"湖南":18, u"广东":19, u"广西":20, 
                             u"海南":21, u"重庆":22, u"四川":23, u"贵州":24, u"云南":25, u"西藏":26, u"陕西":27, u"甘肃":28, u"青海":29, u"宁夏":30, 
                             u"新疆":31, u"台湾":32, u"香港":33, u"澳门":34}
                menu_select = driver.find_element_by_name("sc_id[]").find_elements_by_tag_name("option")
                nselect = city_list[addefaultcity_list[i]]
                menu_select[nselect].click()
            
            #输入广告描述
            driver.find_element_by_id("ad_desc").send_keys(addescription_list[i])
            
            try:
                #点击保存按钮
                driver.find_element_by_css_selector(".fsub>button").click()
                
                #接收弹窗
                if 1 == addefault_nselect:
                    driver.switch_to_alert().accept()
                
                #断言
                time.sleep(2)
                self.assertEqual(exception_result_list[i], driver.find_element_by_css_selector(".ajax_build_tip").text)  
            except Exception as e:
                print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e))
                screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_ad_add_errorimg" + now + ".jpg" #错误截图存放路径
                driver.get_screenshot_as_file(screenshot_path)   #错误截屏
                
            finally:
                if common_function.isElementPresent(driver, ".close"):
                    driver.find_element_by_css_selector(".close").click()
                    
                #print u"退前"    
                time.sleep(1)
                #退出百万点系统
                login.logout(driver)
                #print u"退后" 
                #time.sleep(2)
                
            #循环变量自增
            i = i+1
Exemple #32
0
    def test_wifiadmin_addelivery_add(self):
        u'''添加广告投放'''
        #读取数据
        addelivery_name_list = self.xlseng.readcol('sheet3',2)    #广告投放名称
        deliveryad_name_list = self.xlseng.readcol('sheet3',3)    #投放广告名称
        addelivery_type_list = self.xlseng.readcol('sheet3',4)  #投放类型
        delivery_date_list = self.xlseng.readcol('sheet3',5)   #投放日期段
        delivery_time_list = self.xlseng.readcol('sheet3',6)  #投放时间段
        addelivery_model_list = self.xlseng.readcol('sheet3',7)  #投放参数
        addelivery_address_list = self.xlseng.readcol('sheet3',8)   #投放地区
        partner_type_list = self.xlseng.readcol('sheet3',9)   #商户分类
        partner_tip_list = self.xlseng.readcol('sheet3',10)   #商户标签
        delivery_partner_list = self.xlseng.readcol('sheet3',11)   #投放商户名称
        addelivery_description_list = self.xlseng.readcol('sheet3',12)  #投放说明
        exception_result_list = self.xlseng.readcol('sheet3',13)  #预期结果

        nrow = self.xlseng.info('sheet3')[0]   #数据总行数,包括首行
        #print "nrow: %d" %nrow

        i = 1
        while i < nrow:
            #获取当前时间
            now = time.strftime("%Y-%m-%d %H-%M-%S")

            #webdriver驱动
            driver = self.driver
            driver.maximize_window()  #窗口最大化

            #登录百万点系统
            login.login(driver, self.baseurl, 'test', 'testing')

            #点击广告
            driver.find_element_by_css_selector(".ku_fix.quike").find_element_by_xpath("h1[2]").click()

            #点击广告投放
            driver.find_element_by_css_selector("h2[accessid='10']").click()

            #点击投放管理
            driver.find_element_by_css_selector("li[accessid='27']").click()

            #点击“+”号
            driver.find_element_by_css_selector(".add").click()

            #输入广告投放添加所需的各字段信息
            #输入广告投放名称
            driver.find_element_by_css_selector("input[name='delivery_name']").send_keys(addelivery_name_list[i])

            #输入投放广告名称
            if deliveryad_name_list[i]:
                driver.find_element_by_css_selector("input[name='ad_search_key']").send_keys(deliveryad_name_list[i])
                driver.find_element_by_css_selector("button#ad_search").click()
                driver.find_element_by_css_selector(".ad_search_list>ul>li").click()

            #输入投放类型
            if addelivery_type_list[i]:
                addelivery_type_select = {u"定时广告":1, u"推送广告":2}
                driver.find_element_by_name("ad_type_id").click()
                menu_select = driver.find_element_by_name("ad_type_id").find_elements_by_tag_name("option")
                nselect = addelivery_type_select[addelivery_type_list[i]]
                menu_select[nselect].click()

            #输入投放日期段
            delivery_date_startend = delivery_date_list[i].split('|')
            delivery_start_date = delivery_date_startend[0]
            delivery_end_date = delivery_date_startend[1]
            driver.find_element_by_css_selector("input[name='delivery_start_date']").send_keys(delivery_start_date)
            driver.find_element_by_css_selector("input[name='delivery_end_date']").send_keys(delivery_end_date)

            #输入投放时间段
            delivery_time_startend = delivery_time_list[i].split('|')
            delivery_start_time = delivery_time_startend[0]
            delivery_end_time = delivery_time_startend[1]
            driver.find_element_by_css_selector("input[name='delivery_start_time']").send_keys(delivery_start_time)
            driver.find_element_by_css_selector("input[name='delivery_end_time']").send_keys(delivery_end_time)

            #输入投放参数
            addelivery_model_select = {u"综合投放":0, u"商户投放":1}
            radio_select = driver.find_elements_by_name("delivery_parm")
            addelivery_model_nselect = addelivery_model_select[addelivery_model_list[i]]
            radio_select[addelivery_model_nselect].click()

            if u'商户投放' == addelivery_model_list[i]:
                #输入商户
                if delivery_partner_list[i]:
                    driver.find_element_by_css_selector("input[name='partner_search_key']").send_keys(delivery_partner_list[i])
                    driver.find_element_by_css_selector("button#partner_search").click()
                    driver.find_element_by_css_selector("div.partner_search_list>ul>li").click()

            elif u'综合投放' == addelivery_model_list[i]:
                #输入投放地区
                addelivery_address_province = {u"全国":0, u"北京":11, u"天津":12, u"河北":13, u"山西":14, u"内蒙古":15, u"辽宁":21, u"吉林":22, u"黑龙江":23,
                                       u"上海":31, u"江苏":32, u"浙江":33, u"安徽":34, u"福建":35, u"江西":36, u"山东":37, u"河南":41, u"湖北":42, u"湖南":43,
                                       u"广东":44, u"广西":45, u"海南":46, u"重庆":50, u"四川":51, u"贵州":52, u"云南":53, u"西藏":54, u"陕西":61, u"甘肃":62,
                                       u"青海":63, u"宁夏":64, u"新疆":65, u"台湾":71, u"香港":81, u"澳门":91}

                addelivery_address_city = {u"深圳":4403, u"广州":4401, u"韶关":4402, u"珠海":4404, u"汕头":4405, u"佛山":4406, u"江门":4406, u"湛江":4408,
                                           u"茂名":4409, u"肇庆":4412, u"惠州":4413, u"梅州":4414, u"汕尾":4415, u"河源":4416, u"阳江":4417, u"清远":4418,
                                           u"东莞":4419, u"中山":4420, u"潮州":4421, u"揭阳":4452, u"云浮":4453}

                addelivery_address_area = {u"罗湖区":440303, u"福田区":440304, u"南山区":440305, u"宝安区":440306, u"龙岗区":440307, u"盐田区":440308,
                                           u"坪山新区":910163, u"龙华新区":910165, u"大鹏新区":910166, u"市辖区":440101, u"荔湾区":440103, u"越秀区":440104,
                                           u"海珠区":440105, u"天河区":440106, u"白云区":440111, u"黄埔区":440112, u"番禺区":440113, u"花都区":440114,
                                           u"增城区":440183, u"从化区":440184}

                addelivery_address_cirle = {u"东门":101, u"地王大厦":102, u"国贸":103, u"黄贝岭":104, u"火车站":105, u"万象城":109, u"莲塘":106, u"笋岗":107,
                                            u"CBD中心区":82, u"车公庙":83, u"福田保税区":84, u"岗厦":85, u"华强北":86, u"皇岗":87, u"华强南":88, u"景田":89,
                                            u"梅林":90, u"市民中心":92, u"香蜜湖":95, u"竹子林":96, u"科学城":1042, u"开发区东区":1043, u"开发区西区":1044,
                                            u"中心城":1045, u"其他(广州)":1080}

                if addelivery_address_list[i]:
                    addelivery_address = addelivery_address_list[i].split('|')
                    naddress = len(addelivery_address)
                    if 0 < naddress:
                        #输入省份
                        driver.find_element_by_css_selector("select[name='sc_id[]']").click()
                        nprovince = addelivery_address_province[addelivery_address[0]]
                        elestr_nprovince = "option[value='" + str(nprovince) + "']"
                        driver.find_element_by_css_selector("select[name='sc_id[]']").find_element_by_css_selector(elestr_nprovince).click()
                        if 1 < naddress:
                            #输入城市
                            time.sleep(1)
                            driver.find_elements_by_css_selector("select[name='sc_id[]']")[1].click()
                            ncity = addelivery_address_city[addelivery_address[1]]
                            elestr_ncity = "option[value='" + str(ncity) + "']"
                            driver.find_elements_by_css_selector("select[name='sc_id[]']")[1].find_element_by_css_selector(elestr_ncity).click()
                            if 2 < naddress:
                                #输入区
                                time.sleep(1)
                                driver.find_elements_by_css_selector("select[name='sc_id[]']")[2].click()
                                narea = addelivery_address_area[addelivery_address[2]]
                                elestr_narea = "option[value='" + str(narea) + "']"
                                driver.find_elements_by_css_selector("select[name='sc_id[]']")[2].find_element_by_css_selector(elestr_narea).click()
                                if 3 < naddress:
                                    #输入商圈
                                    driver.find_element_by_css_selector("select[name='area_id[]']").click()
                                    ncirle = addelivery_address_cirle[addelivery_address[3]]
                                    elestr_ncirle = "option[value='" + str(ncirle) + "']"
                                    driver.find_element_by_css_selector("select[name='area_id[]']").find_element_by_css_selector(elestr_ncirle).click()
                    #点击添加按钮
                    driver.find_element_by_css_selector("button#add_area").click()

                #输入商户分类
                partner_type1 = {u"全部":0, u"餐饮美食":1, u"娱乐休闲":2, u"都市丽人":37, u"婚嫁服务":39, u"购物零售":40, u"家庭亲子":41, u"运动健身":74,
                                 u"酒店住宿":89, u"汽车服务":90, u"生活服务":91, u"公共交通":229}

                partner_type2 = {u"北京菜":92, u"火锅":93, u"日本菜":94, u"西餐":95, u"自助餐":96, u"面包甜点":97, u"韩国料理":98, u"川菜":99, u"鲁菜":100,
                                 u"湘菜":101, u"湖北菜":102, u"江浙菜":103, u"粤菜":104, u"东北菜":105, u"清真菜":106, u"新疆菜":107, u"西北菜":108,
                                 u"云南菜":109, u"贵州菜":110, u"素菜":111, u"海鲜":112, u"小吃快餐":113, u"东南亚菜":114, u"其他":115, u"烧烤":221,
                                 u"茶饮":226, u"茶餐厅":227, u"微菜":236}

                if partner_type_list[i]:
                    partner_type = partner_type_list[i].split('|')
                    npartner_type = len(partner_type)
                    if 0 < npartner_type:
                        driver.find_element_by_css_selector("select[name='cat_id[]']").click()
                        npartner_type1 = partner_type1[partner_type[0]]
                        elestr_type1 = "option[value='" + str(npartner_type1) + "']"
                        driver.find_element_by_css_selector("select[name='cat_id[]']").find_element_by_css_selector(elestr_type1).click()
                        if 1 < npartner_type:
                            time.sleep(1)
                            driver.find_elements_by_css_selector("select[name='cat_id[]']")[1].click()
                            npartner_type2 = partner_type2[partner_type[1]]
                            elestr_type2 = "option[value='" + str(npartner_type2) + "']"
                            driver.find_elements_by_css_selector("select[name='cat_id[]']")[1].find_element_by_css_selector(elestr_type2).click()

                    #点击添加按钮
                    driver.find_element_by_css_selector("button#add_cate").click()

                #输入商户标签
                partner_tip = {u"全部":0, u"商务":7, u"养生":8, u"送礼":9, u"电影":10, u"聚餐":11, u"宴请":12, u"约会":13}
                if partner_tip_list[i]:
                    npartner_tip = partner_tip[partner_tip_list[i]]
                    elestr_tip = "option[value='" + str(npartner_tip) + "']"
                    driver.find_element_by_css_selector("select[name='tag_id[]']").find_element_by_css_selector(elestr_tip).click()

                    #点击添加按钮
                    driver.find_element_by_css_selector("button#add_tag").click()
            else:
                print "addelivery_model is error!"

            #输入投放说明
            driver.find_element_by_css_selector("textarea[name='delivery_desc']").send_keys(addelivery_description_list[i])

            try:
                #点击保存按钮
                driver.find_element_by_css_selector(".fsub>button").click()

                #断言
                time.sleep(2)
                self.assertEqual(exception_result_list[i], driver.find_element_by_css_selector(".ajax_build_tip").text)

            except Exception as e:
                print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e))
                screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_addelivery_add_errorimg" + now + ".jpg" #错误截图存放路径
                driver.get_screenshot_as_file(screenshot_path)   #错误截屏

            finally:
                if common_function.isElementPresent(driver, ".close"):
                    driver.find_element_by_css_selector(".close").click()

                #退出百万点系统
                time.sleep(1)
                login.logout(driver)

            #循环变量自增
            i = i+1
Exemple #33
0
    def test_wifiadmin_ad_modify(self):
        u'''修改广告'''
        #获取当前时间
        now = time.strftime("%Y-%m-%d %H-%M-%S")
        chuo_now = time.time()

        #webdriver驱动
        driver = self.driver
        driver.maximize_window()  #窗口最大化

        #登录百万点系统
        login.login(driver, self.baseurl, 'test', 'testing')

        #点击广告
        driver.find_element_by_css_selector(
            ".ku_fix.quike").find_element_by_xpath("h1[2]").click()

        #点击广告&广告位
        driver.find_element_by_css_selector("h2[accessid='11']").click()

        #点击广告基本信息
        driver.find_element_by_css_selector("li[accessid='32']").click()

        #修改一条广告
        ad_driver_list = driver.find_elements_by_css_selector(
            ".b_table>tbody>tr")
        ad_driver_list[4].find_element_by_css_selector(
            "button[onclick]").click()

        #输入广告名称
        ad_name_dr = driver.find_element_by_css_selector("#ad_name")
        ad_name_new = "testadname" + str(chuo_now)
        ad_name_dr.clear()
        ad_name_dr.send_keys(ad_name_new)

        #输入广告分类
        driver.find_element_by_css_selector("#ad_cate_id").click()
        driver.find_element_by_css_selector(
            "#ad_cate_id").find_elements_by_tag_name("option")[7].click()

        #输入所属广告主
        driver.find_element_by_id("source_id").click()
        driver.find_element_by_id("source_id").find_elements_by_tag_name(
            "option")[2].click()

        #文件上传
        driver.find_element_by_id("ad_up_file").click()
        os.system(
            r"E:\Code\yzhselenium\test_wifiadmin\testcase\tools\upfile.exe")

        #输入目标网址
        driver.find_element_by_id("ad_link").send_keys("http://m.100msh.com")

        #输入广告描述
        driver.find_element_by_id("ad_desc").send_keys(
            "test ad modiy discription")

        try:
            #点击保存按钮
            driver.find_element_by_css_selector(".fsub>button").click()

            self.assertEqual(
                u"广告修改成功!",
                driver.find_element_by_css_selector(".ajax_build_tip").text)
        except Exception as e:
            print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e))
            screenshot_path = "E:\\Code\\yzhselenium\\test_wifiadmin\\report\\test_ad_modify_errorimg" + now + ".jpg"  #错误截图存放路径
            driver.get_screenshot_as_file(screenshot_path)  #错误截屏
        finally:
            #退出百万点系统
            time.sleep(1)
            login.logout(driver)
 def tearDown(self):
     logout(self.driver)
     self.driver.quit()