def test_switch_lan(self): print("当前语言为===》"+bcomm.get_current_language()) product_head_first = self.get_element("head", "product").text product_foot_first = self.get_element("foot", "product").text bcomm.switch_language() sleep(1) product_head_second = self.get_element("head", "product").text product_foot_second = self.get_element("foot", "product").text if bcomm.get_current_language() == "中文": with my_assert("检查homepage中英文切换"): self.assertEqual(product_head_first, "PRODUCTS") self.assertEqual(product_head_second, "产品") map = self.get_element("contactuspage", "map_img") self.assertIsNotNone(map) self.assertEqual(product_foot_first, "PRODUCTS") self.assertEqual(product_foot_second, "产品") else: with my_assert("检查homepage中英文切换"): self.assertEqual(product_head_second, "PRODUCTS") self.assertEqual(product_head_first, "产品") map = self.get_element("contactuspage", "map_google") self.assertIsNotNone(map) self.assertEqual(product_foot_second, "PRODUCTS") self.assertEqual(product_foot_first, "产品")
def test_deposit_btc(self): open_url(get_url("deposit_btc")) sleep(3) with my_assert(u"充值 btc 检查二维码显示"): self.assertIsNotNone(self.get_element("deposit", "btc_qrcode")) with my_assert(u"充值 btc 检查地址显示"): self.assertIsNotNone(self.get_element("deposit", "btc_address"))
def check_result(self): sleep(2) # 检查登陆后的账户 显示是否正确 value = self.get_element("homepage", "email_text").text with my_assert("登陆成功"): self.assertEqual(self.user.get("email"), value) # 检查btc和ltc价格显示 btc = self.get_element("homepage", "BTC/CNY_price").text with my_assert("balance btc 显示"): self.assertNotEqual(btc, "") ltc = self.get_element("homepage", "LTC/CNY_price").text with my_assert("balance btc 显示"): self.assertNotEqual(ltc, "") # 检查语言切换 print("当前语言为===》"+bcomm.get_current_language()) product_head_first = self.get_element("head", "product").text complete_first = self.get_element("homepage", "COMPLETE").text product_foot_first = self.get_element("foot", "product").text bcomm.switch_language() sleep(2) product_head_second = self.get_element("head", "product").text complete_second = self.get_element("homepage", "COMPLETE").text product_foot_second = self.get_element("foot", "product").text if bcomm.get_current_language() == "中文": with my_assert("检查homepage中英文切换"): self.assertEqual(product_head_first, "PRODUCTS") self.assertEqual(product_head_second, "产品") self.assertEqual(complete_first, "THE COMPLETE") self.assertEqual(complete_second, "一站式完整") self.assertEqual(product_foot_first, "PRODUCTS") self.assertEqual(product_foot_second, "产品") else: with my_assert("检查homepage中英文切换"): self.assertEqual(product_head_second, "PRODUCTS") self.assertEqual(product_head_first, "产品") self.assertEqual(complete_second, "THE COMPLETE") self.assertEqual(complete_first, "一站式完整") self.assertEqual(product_foot_second, "PRODUCTS") self.assertEqual(product_foot_first, "产品")
def test_deposit_cny(self): open_url(get_url("deposit_cny")) sleep(2) self.get_element("deposit", "select_bank").click() sleep(1) self.get_element("deposit", "first_bank").click() sleep(1) self.get_element("deposit", "amount").send_keys(self.get_random()) amount = self.get_element("deposit", "amount").get_attribute("value") amount_decimal = self.get_element("deposit", "amount-decimal").text value = amount+amount_decimal print("========> "+value) self.get_element("deposit", "create_request").click() while self.get_element("deposit", "create_request_loading") is not None: sleep(1) sleep(2) with my_assert(u"充值 cny"): value2 = self.get_element("deposit", "transfer_info_amount").text self.assertEqual(value, value2.replace(",", "")) print(self.get_element("deposit", "close")) while self.get_element("deposit", "close").is_displayed(): self.get_element("deposit", "close").click() sleep(2) while self.get_element("deposit", "cancel").is_displayed(): self.get_element("deposit", "cancel").click() sleep(2) if self.get_element("deposit", "confirm_cancel").is_displayed(): self.get_element("deposit", "confirm_cancel").click() sleep(2) break
def check_result(self, before_orders, after_orders, msg): sleep(2) if after_orders-3 == before_orders: with my_assert(msg): self.assertEqual(1, 1) # open_order_title = self.get_element("trade", "open_orders_title") # sleep(4) # self.driver.execute("arguments[0].scrollIntoView()", open_order_title) sleep(4) self.get_element("trade", "cancle_first_orders_table_tr").click() sleep(4)
def test_cny_trading(self): self.get_element("propage", "cny_trading").click() sleep(3) # handels = self.driver.window_handles # self.driver.switch_to_window(handels[1]) # sleep(2) url = self.driver.current_url with my_assert("点击cny_trading 进入trading 页面"): self.assertEqual(url, get_url("propage_cny_trading")) # 关闭导航 self.get_element("propage_cny_trade", "note_confirm_btn").click() sleep(1) self.get_element("propage_cny_trade", "guide_colse_btn").click() sleep(1) # 检查语言切换 self.get_element("propage_cny_trade", "trade_current_language_div").click() # 切换英文 self.get_element("propage_cny_trade", "trade_en_language").click() sleep(1) value = self.get_element("propage_cny_trade", "order_book").text with my_assert("cny_trading 切换英文"): self.assertEqual(value, "ORDER BOOK") self.get_element("propage_cny_trade", "trade_current_language_div").click() # 切换中文 self.get_element("propage_cny_trade", "trade_ch_language").click() sleep(1) value = self.get_element("propage_cny_trade", "order_book").text with my_assert("cny_trading 切换中文"): self.assertEqual(value, "盘口")
def test_pro_switch_lan(self): sleep(3) print("当前语言为===》"+bcomm.get_current_language()) product_head_first = self.get_element("head", "product").text cny_trading_first = self.get_element("propage", "cny_trading").text product_foot_first = self.get_element("foot", "product").text bcomm.switch_language() print("当前语言为===》"+bcomm.get_current_language()) sleep(1) product_head_second = self.get_element("head", "product").text cny_trading_second = self.get_element("propage", "cny_trading").text product_foot_second = self.get_element("foot", "product").text if bcomm.get_current_language() == "中文": with my_assert("检查propage中英文切换"): self.assertEqual(product_head_first, "PRODUCTS") self.assertEqual(product_head_second, "产品") self.assertEqual(cny_trading_first, "CNY Trading\nCNY Trading") self.assertEqual(cny_trading_second, "人民币交易市场\n人民币交易市场") self.assertEqual(product_foot_first, "PRODUCTS") self.assertEqual(product_foot_second, "产品") else: with my_assert("检查propage中英文切换"): self.assertEqual(product_head_second, "PRODUCTS") self.assertEqual(product_head_first, "产品") self.assertEqual(cny_trading_second, "CNY Trading\nCNY Trading") self.assertEqual(cny_trading_first, "人民币交易市场\n人民币交易市场") self.assertEqual(product_foot_second, "PRODUCTS") self.assertEqual(product_foot_first, "产品")
def test_withdraw_btc(self): open_url(get_url("withdraw_btc")) sleep(2) self.get_element("withdraw", "withdraw_amount").send_keys("0.001") self.get_element("withdraw", "withdraw_trans_password").send_keys(self.user.get("trans_password")) sleep(1) self.get_element("withdraw", "withdraw_btn").click() sleep(0.1) while self.get_element("withdraw", "withdraw_btn_loading") is not None: sleep(1) sleep(3) with my_assert("提现 btc"): self.assertTrue(self.get_element("withdraw", "success_msg").is_displayed()) self.get_element("withdraw", "cancel").click() sleep(1) self.get_element("withdraw", "confirm").click() while self.get_element("withdraw", "confirm_loading") is not None: sleep(1)
def test(self): with my_assert("测试发邮件"): self.assertEqual("!", "1")
def check_result(self): sleep(2) # 检查登陆后的账户 显示是否正确 value = self.get_element("homepage", "email_text").text # value = 'ken***@gmail.com' with my_assert("登陆成功"): self.assertEqual('ken***@gmail.com', value) # 检查页面跳转是否正常 self.get_element("homepage", "trade").click() sleep(1) url = self.driver.current_url with my_assert("点击trade链接跳转"): self.assertEqual(url, get_url("trade")) self.driver.back() sleep(2) self.get_element("homepage", "market_trend").click() sleep(1) url = self.driver.current_url with my_assert("点击market Trend 链接跳转"): self.assertEqual(url, get_url("market_trend")) self.driver.back() sleep(2) # self.get_element("homepage", "help_center").click() # handels = self.driver.window_handles # self.driver.switch_to_window(handels[1]) # sleep(2) # url = self.driver.current_url # with my_assert("点击help center 链接跳转"): # self.assertEqual(url, get_url("help_center")) # # self.driver.close() # self.driver.switch_to_window(handels[0]) # sleep(2) # # self.driver.refresh() # sleep(2) self.get_element("homepage", "deposit_withdraw").click() url = self.driver.current_url with my_assert("点击withdraw deposit链接跳转"): self.assertEqual(url, get_url("deposit_cny")) self.driver.back() sleep(2) # 检查账户信息是否显示出来 total_assets = self.get_element("homepage", "total_assets").text with my_assert("total assets 显示"): self.assertNotEqual(total_assets, "") available = self.get_element("homepage", "available").text with my_assert("available 显示"): self.assertNotEqual(available, "") balance_btc = self.get_element("homepage", "balance_btc").text with my_assert("balance btc 显示"): self.assertNotEqual(balance_btc, "") balance_ltc = self.get_element("homepage", "balance_ltc").text with my_assert("balance ltc 显示"): self.assertNotEqual(balance_ltc, "") # 检查btc/cny 和 ltc/cny的价格是否正常的显示出来 self.get_element("homepage", "BTC/CNY").click() last_price = self.get_element("homepage", "last_price").text with my_assert("btc/cny last_price 显示"): self.assertNotEqual(last_price, "") daily_high = self.get_element("homepage", "daily_high").text with my_assert("btc/cny daily_high 显示"): self.assertNotEqual(daily_high, "") daily_low = self.get_element("homepage", "daily_low").text with my_assert("btc/cny daily_low 显示"): self.assertNotEqual(daily_low, "") self.get_element("homepage", "LTC/CNY").click() last_price = self.get_element("homepage", "last_price").text with my_assert("ltc/cny last_price 显示"): self.assertNotEqual(last_price, "") daily_high = self.get_element("homepage", "daily_high").text with my_assert("ltc/cny daily_high 显示"): self.assertNotEqual(daily_high, "") daily_low = self.get_element("homepage", "daily_low").text with my_assert("ltc/cny daily_low 显示"): self.assertNotEqual(daily_low, "")