project > page > order_page.py
project > testcases > order_center > test_order.py
# project > page > order_page.py
from selenium.webdriver.common.by import By
from base.base_page import BasePage
class OrderPage(BasePage):
# 首页商品
first_good = (By.CSS_SELECTOR, '.newgoods_fastbuy>li>div>a')
# 点击加入购物车
add_shopping_cart = (By.ID, 'buy_btn')
# 点击去结算
go_pay = (By.XPATH, '//*[@id="cart_show"]/div[2]/a[2]')
# 选择地址
select_address = (By.XPATH, '//p[contains(text(),"配送地址")]/following-sibling::ul/li[2]')
# 选择支付方式
select_alipay = (By.XPATH, '//p[contains(text(),"支付方式")]/following-sibling::p/img')
# 留言
input_message = (By.XPATH, '//*[@id="cart-box"]/div[3]/textarea')
# 去结算
submit_order = (By.XPATH, '//*[@id="cart-box"]/div[3]/p/a')
# 创建订单商品
order_good = (By.XPATH, '//*[@id="cart-box"]/div[2]/ul/li')
# project > testcases > order_center > test_order.py
import allure
import pytest
from page.order_page import OrderPage
from page.user_page import UserPage
from utils.assert_util import assert_compare
@allure.epic("美客生鲜的项目")
@allure.feature("订单中心")
@pytest.mark.run(order=2)
class TestOrder:
@allure.title("创建订单")
def test_add_order(self, driver_project):
user_page = UserPage(driver_project)
order_page = OrderPage(driver_project)
# user_page.login()
order_page.get_url('http://meikefresh.5istudy.online/')
order_page.click(order_page.first_good)
order_page.switch_to_window()
order_page.click(order_page.add_shopping_cart)
order_page.click(order_page.go_pay)
order_page.wait_ele_presence(order_page.order_good)
order_page.click(order_page.select_address)
order_page.click(order_page.select_alipay)
order_page.send_keys(order_page.input_message, "测试订单")
order_page.click(order_page.submit_order)
text = order_page.popup_window_operation(get_window_info=True)
assert_compare("订单创建成功", "==", text)
order_page.popup_window_operation()
order_page.close_driver()
order_page.switch_to_window(to_parent_window=True)
网友评论