• selenium+python笔记9


    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    """
    @desc:        delete mail
    我们多添加一些测试场景,比如:删除邮件,查找邮件,发送邮件等等
    """
    import unittest
    import os
    import sys
    from selenium import webdriver
    
    cur_dir = os.getcwd()
    sys.path.append(cur_dir.split(r'	est_case')[0])
    
    from public import login
    
    
    # from selenium.webdriver.common.keys import Keys
    import time
    
    
    class TestDel(unittest.TestCase):
        def setUp(self):
            self.driver = webdriver.Firefox()
            self.driver.implicitly_wait(30)
            self.base_url = "http://www.126.com/"
            self.verificationErrors = []
            self.accept_next_alert = True
    
        # 搜索邮件
        def test_del_mail(self):
            driver = self.driver
            driver.get(self.base_url)
            # 调用登录模块
            login.login(self, 'xxxx', 'xxxx')
            # 打开收件箱
            driver.find_element_by_class_name('nui-tree-item-text').click()
            time.sleep(2)
            driver.find_elements_by_xpath("//span[@class='nui-chk-symbol']/b").pop(1).click()
            try:
                spans = driver.find_elements_by_tag_name('span')
                for s in spans:
                    if s.text == u'删 除':
                        s.click()
            except:
                pass
            # 断言是否已删除
            text = driver.find_element_by_css_selector("span.nui-tips-text>a").text
            self.assertEqual(text, u'已删除')
            # 退出
            login.logout(self)
    
        def tearDown(self):
            self.driver.quit()
            self.assertEqual([], self.verificationErrors)
    
    
    if __name__ == "__main__":
        unittest.main()
  • 相关阅读:
    [Matlab.Matrix] 作为判断条件
    [Matlab.GUI] 学习小结
    [Modelsim] 初识
    [Matlab] isnan
    [Matlab] round
    [VS2012] 无法查找或打开 PDB 文件
    [Matlab.GUI]初识
    表格特效代码全集中
    JAVASCRIPT基础
    第4天:调用样式表
  • 原文地址:https://www.cnblogs.com/kuihua/p/5510762.html
Copyright © 2020-2023  润新知