Esempio n. 1
0
class TestInvest(unittest.TestCase):

    def setUp(self):
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        # 登录
        self.driver = webdriver.Chrome(
            executable_path=(PD.driver_path),
            chrome_options=chrome_options)
        self.driver.maximize_window()
        self.driver.get(PD.login_url)
        self.bid_page = BidPage(self.driver)
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.person_page = PersonPage(self.driver)
        self.login_page.login(PD.username, PD.password)

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

    def test_invest_success(self):
        # 进入个人详情页面,查看当前账户余额
        self.index_page.change_to_person_page()
        before_invest = self.person_page.get_balance()
        # 返回首页
        self.driver.back()
        time.sleep(5)
        # 首页选择一个标来进行投资
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(ID.input_money)
        self.bid_page.click_submit_button()
    #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.success_invest_msg(),ID.expect_success_invest_msg)
        # 投资成功,查看并激活
        self.bid_page.click_active_button()
    #     进入个人详情页面,读取投资后的个人账户余额
        # 刷新
        self.driver.refresh()
        time.sleep(2)
        after_invest = self.person_page.get_balance()
        self.assertEqual(int(float(before_invest)-float(after_invest)), ID.input_money)

    def test_invest_failed_by_No100(self):
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(150)
        self.bid_page.click_submit_button()
        #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.fail_invest_by_no100(), ID.expext_msg_by_no100)

    def test_invest_failed_by_No10(self):
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(15)
        #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.fail_invest_by_no10(), ID.expext_msg_by_no10)
Esempio n. 2
0
class TestInvest(unittest.TestCase):

    def setUp(self):
		#设置无头浏览器
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        # 登录
        self.driver = webdriver.Chrome(executable_path=(r"C:\Users\yujing\AppData\Local\Programs\Python\Python37\chromedriver.exe"), chrome_options=chrome_options)
        self.driver.maximize_window()
        self.driver.get("http://120.79.176.157:8012/Index/login.html")
        self.bid_page = BidPage(self.driver)
        self.login_page = LoginPage(self.driver)
        self.index_page = IndexPage(self.driver)
        self.person_page = PersonPage(self.driver)
        self.login_page.login("18684720553", "python")

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

    def test_invest_success(self):

        # 进入个人详情页面,查看当前账户余额
        self.index_page.change_to_person_page()
        before_invest = self.person_page.get_balance()
        # 返回首页
        self.driver.back()
        time.sleep(5)
        # 首页选择一个标来进行投资
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(1000)
        self.bid_page.click_submit_button()
    #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.success_invest_msg(),"投标成功!")
        # 投资成功,查看并激活
        self.bid_page.click_active_button()
    #     进入个人详情页面,读取投资后的个人账户余额
        # 刷新
        self.driver.refresh()
        time.sleep(2)
        after_invest = self.person_page.get_balance()
        self.assertEqual(int(float(before_invest)-float(after_invest)), 1000)

    def test_invest_failed_by_No100(self):
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(150)
        self.bid_page.click_submit_button()
        #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.fail_invest_by_no100(), "投标金额必须为100的倍数")

    def test_invest_failed_by_No10(self):
        self.index_page.click_firstbid()
        self.bid_page.input_invest_balance(15)
        #     投资成功,读取提示信息
        self.assertEqual(self.bid_page.fail_invest_by_no10(), "请输入10的整数倍")