Ejemplo n.º 1
0
class TestLogin(unittest.TestCase):
    """登录测试用例"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.maximize_window()
        self.stg = LoginPage(self.driver)

    @ddt.data(*d1)
    def test_login(self, test_data):
        """不同条件下的登录"""
        usr = test_data["usr"]
        psw = test_data["psw"]
        exp = test_data["except"]
        self.stg.login(usr, psw)
        result = self.stg.get_login_result()
        if result == "admin":
            print("登录成功")
            actual = True
        else:
            print("登录失败")
            actual = False
        self.assertTrue(exp == actual)

    def tearDown(self):
        self.driver.quit()
Ejemplo n.º 2
0
class Test_LoginModule(unittest.TestCase):

    logger = Logger("info").getLog()

    def setUp(self):
        print("开始测试")

    @ddt.file_data(r"C:\Users\loudDD\GitProject\svoc\svoc\public\accout.yaml")
    @ddt.unpack
    def test_login(self, **data):
        try:
            username = data.get("username")
            pwd = data.get("pwd")
            result = data.get("result")
            self.case = LoginPage()
            self.case.login(username, pwd)
            self.assertTrue(result == self.case.driver.current_url)
            self.logger.info("pass")
        except Exception as e:
            self.filename = os.path.join("{0}screenshot.png".format(
                time.strftime("%Y-%m-%d-%H-%M-%S")))
            self.imgpath = os.path.join(os.path.abspath("../"), "screenshot")
            self.path = os.path.join(self.imgpath, self.filename)
            self.case.screen(self.path)
            self.logger.critical(
                (e, "已截图", self.filename))  #需要括号括起来,以达到传入一个元素(多个信息)

    def tearDown(self):
        self.case.driver.quit()
        print('测试结束')
Ejemplo n.º 3
0
class TestLoginPage(BasePage):
    def setUp(self):
        super(TestLoginPage, self).setUp()
        self.home_page = HomePage()
        self.login_page = LoginPage()

    @pytest.mark.run(order=1)
    @allure.story('测试-登录')
    def test_login(self):
        self.home_page.home_pwd_login()
        self.login_page.login()
        # assert  account_name in str(self.driver.page_source).encode("utf-8")
        logger.info("登录成功...")
Ejemplo n.º 4
0
class TestBrandShow(unittest.TestCase):
    """显示品牌测试用例"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.lg = LoginPage(self.driver)
        self.lg.login()
        self.edit = BrandMange(self.driver)

    def test_brand_show(self):
        """显示品牌:test锤子001"""
        self.edit.brand_display("test锤子001")
        t = self.edit.brand_query("test锤子001", 6)
        self.assertEqual(t, "有效")

    def tearDown(self):
        self.driver.quit()
Ejemplo n.º 5
0
class TestEditSupplier(unittest.TestCase):
    """编辑供应商测试用例"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.lg = LoginPage(self.driver)
        self.lg.login()
        self.edit = SupplierMange(self.driver)

    def test_supplier_edit(self):
        """编辑供应商:test003"""
        self.edit.supplier_edit("test003", "test003456")
        t = self.edit.supplier_query("test003456")
        self.assertEqual(t, "test003456")

    def tearDown(self):
        self.driver.quit()
Ejemplo n.º 6
0
class TestAddBrand(unittest.TestCase):
    """添加品牌测试用例"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.stg = LoginPage(self.driver)
        self.stg.login()
        self.add = BrandMange(self.driver)

    def test_brand_add(self):
        """添加品牌:test锤子"""
        self.add.brand_add("test锤子", "10086", r"D:\ppoh75.png")
        q = self.add.brand_query("test锤子", 2)
        self.assertEqual(q, "test锤子")

    def tearDown(self):
        self.driver.quit()
Ejemplo n.º 7
0
class TestEditBrand(unittest.TestCase):
    """编辑品牌测试用例"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.lg = LoginPage(self.driver)
        self.lg.login()
        self.edit = BrandMange(self.driver)

    def test_brand_edit(self):
        """编辑品牌:test锤子"""
        self.edit.brand_edit("test锤子", "test锤子001")
        t = self.edit.brand_query("test锤子001", 2)
        self.assertEqual(t, "test锤子001")

    def tearDown(self):
        self.driver.quit()
Ejemplo n.º 8
0
class TestAddSupplier(unittest.TestCase):
    """添加供应商测试用例"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.get("http://47.97.160.167:8980/weibofenqi-manager/login/index.do")
        self.driver.maximize_window()
        self.stg = LoginPage(self.driver)
        self.stg.login()
        self.add = SupplierMange(self.driver)

    def test_supplier_add(self):
        """添加供应商:test003"""
        self.add.supplier_add("test003")
        t = self.add.supplier_query( "test003")
        self.assertEqual(t, "test003")

    def tearDown(self):
        self.driver.quit()
Ejemplo n.º 9
0
class TestTiJiao(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Firefox()
        self.z = LoginPage(self.driver)
        self.z.login()
        self.a = TiJiao(self.driver)

    def tearDown(self):
        self.driver.quit()

    def test_ti_bug(self):
            timestr = str(time.time())
            self.a.ti_bug(timestr)#提交bug
            #获取bug
            result = self.a.get_bug_list_title_text()
            print(result)

            self.assertEqual(result, "111:"+timestr)
Ejemplo n.º 10
0
        # sleep(1)
        # self.b.click(("xpath", ".//*[@id='menu_accordion']/div[4]/div[2]/ul/li"))
        # sleep(1)
        # self.b.switch_frame(("id", "mainFrame_1"))
        # sleep(1)
        self.b.clear(("css selector", "#_easyui_textbox_input1"))
        sleep(1)
        self.b.send(("css selector", "#_easyui_textbox_input1"), supplier)
        sleep(1)
        self.b.click(("css selector", "#button_search"))
        sleep(1)
        try:
            a = self.b.get_text(
                ("xpath", ".//*[@class='datagrid-btable']/tbody/tr/td[3]/div"))
            return a
        except:
            return ""


if __name__ == "__main__":
    driver = webdriver.Firefox()
    driver.maximize_window()
    sm = SupplierMange(driver)

    from page.loginpage import LoginPage
    lg = LoginPage(driver)
    lg.login()
    # sm.supplier_add("test003")
    # sm.supplier_edit("test003", "test003456")
    sm.supplier_query("test003")
    driver.quit()
Ejemplo n.º 11
0
        sleep(1)
        self.b.clear(("xpath", ".//*[@id='_easyui_textbox_input1']"))
        sleep(1)
        self.b.send(("xpath", ".//*[@id='_easyui_textbox_input1']"), name)
        sleep(1)
        self.b.click(("xpath", ".//*[@id='button_search']"))
        sleep(1)
        self.b.click(("xpath", ".//tr[contains(@id,'2-0')]/td[1]/div/input"))
        sleep(1)
        self.b.click(("xpath", ".//*[@id='button-block']"))
        sleep(1)
        self.b.click(("xpath", ".//*[@id='opter_layout']/div[15]/div[3]/a[1]"))
        sleep(1)
        self.b.click(("xpath", ".//*[@id='opter_layout']/div[15]/div[3]/a"))
        sleep(1)


if __name__ == "__main__":
    driver = webdriver.Firefox()
    driver.maximize_window()
    bd = BrandMange(driver)
    from page.loginpage import LoginPage
    lg = LoginPage(driver)
    lg.login("admin", "666666")
    # bd.brand_add("test锤子", "10086", r"D:\ppoh75.png")
    # q = bd.brand_query("test锤子")
    bd.brand_hide("test锤子001")
    q = bd.brand_query("test锤子001", 6)
    print(q)
    driver.quit()
Ejemplo n.º 12
0
        # self.select_city(city)
        # sleep(3)
        # self.select_district(district)
        # sleep(3)
        # self.select_edu(education)
        sleep(3)
        self.click_sub_button()

    def get_username_title(self):
        try:
            res = self.find_element(self.username_loc).text

            return res

        except:
            print("提交失败!!!返回空字符串")
            return ""


if __name__ == "__main__":
    from selenium import webdriver
    from page.loginpage import LoginPage
    driver = webdriver.Firefox()
    login = LoginPage(driver)
    login.login()
    print("---------11111111111111---------")
    basicinfo = BasicInfo(driver)
    print("-------------2222222222222222222-------")
    basicinfo.sub_basic_info()
    print(basicinfo.get_username_title())
Ejemplo n.º 13
0
            print(all_title)
            t1 = all_title[0].text  # list out of range
            return t1
        except:
            return ""

    def new_get_text(self,  _text):
        r = self.is_text_in_element(self.loc_bug_first, _text=_text)
        return r



if __name__=="__main__":
    driver = webdriver.Firefox()
    from page.loginpage import LoginPage
    z = LoginPage(driver)
    z.login()
    a = TiJiao(driver)

    timestr = str(time.time())
    a.ti_bug(timestr)

    result = a.get_bug_list_title_text()
    print(result)

    r1 = a.new_get_text("测试的标题:"+timestr)
    print("新方法的结果: %s"%r1)
    # assert result == "测试的标题:"+timestr


 def setUpClass(cls):
     cls.driver = webdriver.Chrome()
     cls.driver.maximize_window()
     cls.add = Addbug(cls.driver)
     a = LoginPage(cls.driver)
     a.login()