admin alter

This commit is contained in:
licy@guangda.work 2023-05-04 17:31:12 +08:00 committed by Edward Yang
parent 6636986904
commit d434eafec9
28 changed files with 210 additions and 67 deletions

View File

@ -40,8 +40,10 @@ use PHPUnit\TextUI\DefaultResultPrinter;
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\AddCusGroupTest.php');//添加用户组
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\EditCusGroupTest.php');//编辑用户组
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\DelCusGroupTest.php');//删除用户组
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\CusEmptyRecycleTest.php');//清空回收站
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\CustomerRecycleTest.php');//恢复客户信息
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\DelCustomerTest.php');//删除用户
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\CusEmptyRecycleTest.php');//清空回收站
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\DelCustomerTest.php');//删除用户
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\DelCusRecycleTest.php');//从回收站删除客户信息
$suite->addTestFile('.\tests\Browser\dusktest\page\admin\AddExpressTest.php');//添加快递公司
@ -54,6 +56,7 @@ use PHPUnit\TextUI\DefaultResultPrinter;
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\CreateCategoriesTest.php');//添加商品分类
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\EnableProductTest.php');//启用商品
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\DisableProductTest.php');//禁用商品
$suite->addTestFile('.\tests\Browser\dusktest\page\combine\UnderstockOrderTest.php');//库存不足下单
// 运行测试套件
$result = $suite->run();

View File

@ -2,20 +2,24 @@
const admin_top = [
"login_url" =>"/admin",
"root"=> ".text-dark.ml-2",
"mg_index"=>".navbar.navbar-left li:nth-child(1)",//管理首页
"mg_order"=>".navbar.navbar-left li:nth-child(2)",//管理订单
"mg_product"=>".navbar.navbar-left li:nth-child(3)",//管理商品
"mg_customers"=>".navbar.navbar-left li:nth-child(4)",//管理客户
"mg_article"=>".navbar.navbar-left li:nth-child(5)",//管理文章
"system_set"=>".navbar.navbar-left li:nth-child(6)",//系统设置
"mg_index"=>".list-unstyled.navbar-nav li:nth-child(1)",//管理首页 .list-unstyled.navbar-nav
"mg_order"=>".list-unstyled.navbar-nav li:nth-child(2)",//管理订单
"mg_product"=>".list-unstyled.navbar-nav li:nth-child(3)",//管理商品
"mg_customers"=>".list-unstyled.navbar-nav li:nth-child(4)",//管理客户
"mg_article"=>".list-unstyled.navbar-nav li:nth-child(5)",//管理文章
"mg_design"=>".list-unstyled.navbar-nav li:nth-child(6)",//设计
"mg_plugin"=>".list-unstyled.navbar-nav li:nth-child(7)",//插件
"system_set"=>".list-unstyled.navbar-nav li:nth-child(8)",//系统设置
'go_catalog'=>'.dropdown-menu.dropdown-menu-end.show li:nth-child(1)',//去往前台
"sign_out"=> ".dropdown-menu.dropdown-menu-end.show li:nth-child(3)",//退出登录
'personal_center'=>'.dropdown-menu.dropdown-menu-end.show li:nth-child(2)',//个人中心
"sign_out"=> ".dropdown-menu.dropdown-menu-end.show li:nth-child(4)",//退出登录
"Alter"=>".navbar.navbar-right li:nth-child(1)",//更新按钮
"VIP"=>".navbar.navbar-right li:nth-child(2)",//vip图标
"plugins_market"=>".navbar.navbar-right li:nth-child(3)",//插件市场
"sw_language"=>".navbar.navbar-right li:nth-child(4)",//切换语言
"buy_copyright"=>".navbar.navbar-right li:nth-child(3)",//版权购买
"plugins_market"=>".navbar.navbar-right li:nth-child(4)",//插件市场
"sw_language"=>".navbar.navbar-right li:nth-child(5)",//切换语言
"en_language"=>".dropdown-menu.dropdown-menu-end.show li:nth-child(2)",//切换英语
"ch_language"=>".dropdown-menu.dropdown-menu-end.show li:nth-child(8)",//切换中文
"ch_language"=>".dropdown-menu.dropdown-menu-end.show li:nth-child(9)",//切换中文
];
const admin_assert = [
"vip_assert"=>"登录购买VIP服务",

View File

@ -0,0 +1,13 @@
<?php
const article_left = [
"url" =>"/admin/pages",
"mg_article"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(1)",//文章管理
"catalog_article"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(2)",//文章分类
];
const article_common = [
"add_btn"=>"#content > div.container-fluid.p-0 > div > div > div.d-flex.justify-content-between.mb-4 > a",//添加按钮
"edit_btn"=>"#content > div.container-fluid.p-0 > div > div > div.table-push > table > tbody > tr:nth-child(1) > td.text-end > a",//编辑按钮
"del_btn"=>"#content > div.container-fluid.p-0 > div > div > div.table-push > table > tbody > tr:nth-child(1) > td.text-end > button",//删除按钮
];

View File

@ -16,6 +16,7 @@ const alter_product = [
"origin_price"=>"500",//原价
"cost_price"=>"50",//成本价
"quantity"=>"30",//数量
"low_quantity"=>"5",//少量商品 ,测试库存不足
];

View File

@ -1,9 +1,12 @@
<?php
const customer_left = [
"url" =>"/admin/customers",
"customer_list"=>"客户列表",//客户列表
"customer_group"=>"客户组",//客户组
"re_station"=>"回收站",//回收站
// "customer_list"=>"客户列表",//客户列表
// "customer_group"=>"客户组",//客户组
// "re_station"=>"回收站",//回收站
"customer_list"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(1)",//客户列表
"customer_group"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(2)",//客户组
"re_station"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(3)",//回收站
];
const cre_customer = [
"name" =>"#customer-app > div.el-dialog__wrapper > div > div.el-dialog__body > form > div:nth-child(1) > div > div > input",
@ -39,7 +42,7 @@ const customer_group = [
//编辑客户组
"edit_cus_group" =>".btn.btn-outline-secondary.btn-sm",
//删除客户组
"del_cus_group" =>"#customer-app > div.card-body > div.table-push > table > tbody > tr:nth-child(1) > td:nth-child(6) > button.btn.btn-outline-danger.btn-sm.ml-1",
"del_cus_group" =>".btn.btn-outline-danger.btn-sm.ml-1",
"get_assert"=>"#customer-app > div.card-body > div.table-push > table > tbody > tr:nth-child(1) > td:nth-child(2)",
"sure_btn"=>"确定",

View File

@ -0,0 +1,15 @@
<?php
const article_left = [
"url" =>"/admin/themes",
"temp_set"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(1)",//模版设置
"navigate_set"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(2)",//导航设置
"home_decorate"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(3)",//首页装修
"end_decorate"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(4)",//页尾装修
];
const article_common = [
"add_btn"=>"#content > div.container-fluid.p-0 > div > div > div.d-flex.justify-content-between.mb-4 > a",//添加按钮
"edit_btn"=>"#content > div.container-fluid.p-0 > div > div > div.table-push > table > tbody > tr:nth-child(1) > td.text-end > a",//编辑按钮
"del_btn"=>"#content > div.container-fluid.p-0 > div > div > div.table-push > table > tbody > tr:nth-child(1) > td.text-end > button",//删除按钮
];

View File

@ -5,12 +5,17 @@ const order_right = [
"search_bth"=>"#app > div > div > button:nth-child(1)",//搜索按钮
"view_btn"=>"#customer-app > div > div.table-push > table > tbody > tr > td:nth-child(9) > a",//查看按钮
];
const order_child = [
"mg_order" =>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(1)",//订单列表
"mg_sale_after"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(2)",//售后管理
"ca_sale_after"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(3)",//售后原因
];
const order_details = [//订单详情页
"pull_btn"=>"#app > form > div.el-form-item.is-required > div > div > div > span > span > i",//状态栏下拉按钮
// "paid"=>".el-select-dropdown__item",//已支付
"paid"=>".el-scrollbar__view.el-select-dropdown__list li:nth-child(1)",//已支付
"cancel"=>".el-scrollbar__view.el-select-dropdown__list li:nth-child(2)",//已取消
"alter_btn"=>"#app > form > div:nth-child(5) > div > button > span",//更新状态按钮
"alter_btn"=>".el-button.el-button--primary",//更新状态按钮
"Shipped"=>".el-scrollbar__view.el-select-dropdown__list li:nth-of-type(2)",//已发货
"express_btn"=>"#app > form > div:nth-child(3) > div > div > div > span > span > i",//快递下拉按钮
"Completed"=>".el-scrollbar__view.el-select-dropdown__list li:nth-child(1)",//已支付//

View File

@ -11,12 +11,14 @@ const products_top = [
"get_name"=>"#product-app > div > div > div.table-push > table > tbody > tr:nth-child(1) > td:nth-child(4) > a",
];
const products_left = [
"product_cate"=>".list-unstyled.navbar-nav li:nth-child(1)",//商品分类
"product_mg"=>".list-unstyled.navbar-nav li:nth-child(2)",//商品管理
"product_brand"=>".list-unstyled.navbar-nav li:nth-child(3)",//商品品牌
"attribute_group"=>".list-unstyled.navbar-nav li:nth-child(4)",//属性组
"attribute"=>".list-unstyled.navbar-nav li:nth-child(5)",//属性
"Recy_station"=>".list-unstyled.navbar-nav li:nth-child(6)",//回收站
"product_mg"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(1)",//商品管理
"product_cate"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(2)",//商品分类
"product_brand"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(3)",//商品品牌
"attribute_group"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(4)",//属性组
"attribute"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(5)",//属性
"advanced_filter"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(5)",//高级筛选
"Recy_station"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(7)",//回收站
];
const product_cla = [
"cre_cate_btn"=>"#category-app > div > a",//创建分类按钮

View File

@ -1,8 +1,20 @@
<?php
const common = [
"save_btn"=>".btn.btn-lg.btn-primary.submit-form"
const system_common = [
"save_btn"=>".btn.btn-lg.btn-primary.submit-form" //保存按钮
];
const system_left = [
"system_set"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(1)",//系统设置
"personal_center"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(2)",//个人中心
"admin_user"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(3)",//后台用户
"area_group"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(4)",//区域分组
"tax_rate_set"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(5)",//税率设置
"tax_category"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(6)",//税费类别
"currency_mg"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(7)",//货币管理
"language_mg"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(8)",//语言管理
"state_mg"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(9)",//国家管理
"province_mg"=>".list-unstyled.navbar-nav:nth-child(2) li:nth-child(10)",//省份管理
];
const system_set = [
"basic_set"=>".nav.nav-tabs.nav-bordered.mb-5 li:nth-child(1)",//基础设置
"store_set"=>".nav.nav-tabs.nav-bordered.mb-5 li:nth-child(2)",//商店设置

View File

@ -8,7 +8,8 @@ const checkout = [
'assert' => 'Congratulations, the order was successfully generated!',
//订单号
'order_num'=>'.fw-bold',
'view_order'=>'View Order ',
// 'view_order'=>'View Order ',
'view_order'=>'.table.table-borderless tbody tr:nth-of-type(2) td:nth-of-type(2) a',
'method_pay'=>'.radio-line-item',
];

View File

@ -5,10 +5,12 @@ const product = [
"Wishlist_icon"=>".btn.btn-link.ps-0.text-secondary",//收藏
"add_cart"=>".btn.btn-outline-dark.ms-md-3.add-cart.fw-bold",
"product1_name"=>"#product-top > div:nth-child(2) > div > h1",//产品名字
"quantity"=>"#product-top > div:nth-child(2) > div > div.quantity-btns > div > input", //购买商品输入框
"quantity_up"=>".bi.bi-chevron-up",//增加数量按钮
"buy_btn"=> "#product-top > div:nth-child(2) > div > div.quantity-btns > button.btn.btn-dark.ms-3.fw-bold",//购买按钮
"address_btn"=>"#checkout-address-app > div.checkout-black > div.addresses-wrap > div > div > div > button", //添加地址
"login_text"=> "Home",
"understock_assert"=>".layui-layer-content",
];

View File

@ -31,7 +31,7 @@ class AddCusGroupTest extends DuskTestCase
->click(admin_top['mg_customers'])
->pause(3000)
//4.点击客户组
->clickLink(customer_left['customer_group'])
->click(customer_left['customer_group'])
//5.点击创建客户组
->press(customer_group['cre_cus_group'])
//4.填写客户组信息

View File

@ -28,8 +28,10 @@ class AddExpressTest extends DuskTestCase
->type(admin_login['login_pwd'], admin_true_login['password'])
->press(admin_login['login_btn'])
->pause(2000)
//2.点击系统设置
//点击系统
->click(admin_top['system_set'])
//2.点击系统设置
->click(system_left['system_set'])
//3.点击邮件设置
->click(system_set['express_set'])
->pause(2000)

View File

@ -33,9 +33,11 @@ class AddProductTest extends DuskTestCase
->type(admin_login['login_pwd'], admin_true_login['password'])
->press(admin_login['login_btn'])
->pause(2000)
//2.点击商品管理
//2.点击商品
->click(admin_top['mg_product'])
//3.点击添加商品
//2.点击商品管理
->click(products_left['product_mg'])
//3.点击创建
->press(products_top['create_product'])
//4.填写商品信息
->type(product_top['ch_name'], product_info['ch_name'])

View File

@ -31,9 +31,10 @@ class CusEmptyRecycleTest extends DuskTestCase
->type(admin_login['login_pwd'], admin_true_login['password'])
->press(admin_login['login_btn'])
->pause(2000)
//点击客户
->click(admin_top['mg_customers'])
//2.点击回收站
->clickLink(customer_left['re_station'])
->click(customer_left['re_station'])
//3.点击清空回收站
->press(empty_recycle['empty_btn'])
->pause(2000)

View File

@ -19,7 +19,7 @@ class CustomerRecycleTest extends DuskTestCase
public function testEmptyRecycle()
public function testCustomerRecycle()
{
$this->browse(function (Browser $browser)
@ -32,14 +32,14 @@ class CustomerRecycleTest extends DuskTestCase
->pause(2000)
->click(admin_top['mg_customers'])
//2.点击回收站
->clickLink(customer_left['re_station']);
->click(customer_left['re_station']);
$customer_text=$browser->text(empty_recycle['customer_text']);
echo $customer_text;
//3.点击恢复按钮
$browser->press(empty_recycle['recycle_btn'])
->pause(2000)
//4.点击客户列表
->clickLink(customer_left['customer_list'])
->click(customer_left['customer_list'])
//验证客户信息是否存在于页面
->assertSee($customer_text)
;

View File

@ -31,7 +31,7 @@ class DelCusGroupTest extends DuskTestCase
->click(admin_top['mg_customers'])
->pause(3000)
//4.点击客户组
->clickLink(customer_left['customer_group']);
->click(customer_left['customer_group']);
$cus_group_text=$browser->text(customer_group['get_assert']);
echo $cus_group_text;

View File

@ -37,7 +37,7 @@ class DelCusRecycleTest extends DuskTestCase
->press(customer_list['sure_btn'])
->pause(1000)
//2.点击回收站
->clickLink(customer_left['re_station']);
->click(customer_left['re_station']);
$customer_text=$browser->text(empty_recycle['customer_text']);
echo $customer_text;
//3.点击删除按钮

View File

@ -31,7 +31,7 @@ class EditCusGroupTest extends DuskTestCase
->click(admin_top['mg_customers'])
->pause(3000)
//4.点击客户组
->clickLink(customer_left['customer_group'])
->click(customer_left['customer_group'])
//5.点击编辑客户组
->press(customer_group['edit_cus_group'])
//4.填写客户组信息

View File

@ -29,7 +29,7 @@ class EditCustomerTest extends DuskTestCase
->pause(2000)
//2.点击客户管理
->click(admin_top['mg_customers'])
//3.点击删除按钮
//3.点击编辑按钮
->press(customer_list['edit_customer'])
//4.填写客户信息
->type(alter_customer['name'], customer_info_alter['name'])

View File

@ -37,20 +37,16 @@ class Test extends DuskTestCase
->type(admin_login['login_pwd'], admin_true_login['password'])
->press(admin_login['login_btn'])
->pause(2000)
->click(admin_top['mg_product'])
->click(admin_top['mg_order'])
->pause(2000)
->click(products_left['product_cla'])
->click(order_child['mg_order'])
->pause(2000)
->click(products_left['product_mg'])
->click(order_child['mg_sale_after'])
->pause(2000)
->click(products_left['product_brand'])
->pause(2000)
->click(products_left['attribute_group'])
->pause(2000)
->click(products_left['attribute'])
->pause(2000)
->click(products_left['Recy_station'])
->click(order_child['ca_sale_after'])
->pause(2000)
;
});
}

View File

@ -36,9 +36,9 @@ class AlterOrderStationTest extends DuskTestCase
->press(admin_login['login_btn'])
->pause(2000)
//去往前台
->clicklink(admin_top['root'])
->click(admin_top['root'])
->pause(3000)
->clickLink(admin_top['go_catalog'])
->click(admin_top['go_catalog'])
->pause(2000)
//切换到前台下单
->driver->switchTo()->window($browser->driver->getWindowHandles()[1]);
@ -49,7 +49,7 @@ class AlterOrderStationTest extends DuskTestCase
->type(login['login_pwd'], true_login['password'])
->press(login['login_btn'])
->pause(5000)
->clickLink(account['go_index'])
->click(account['go_index'])
//3.向下滑动页面直到找到商品
->pause(2000)
->scrollIntoView(index['product_img'])
@ -66,7 +66,7 @@ class AlterOrderStationTest extends DuskTestCase
$order_num =$elements[15]->getText();
//打印订单号
echo $order_num;
$browser->clickLink(checkout['view_order'])
$browser->click(checkout['view_order'])
//进入后台,修改订单状态为已支付
->driver->switchTo()->window($browser->driver->getWindowHandles()[0]);
//点击订单管理按钮
@ -91,17 +91,16 @@ class AlterOrderStationTest extends DuskTestCase
$browser->pause(3000)
//刷新页面
->refresh()
->pause(5000);
->pause(1000)
// 断言是否已支付
$text = $browser->text(get_order_status['status_text']);
$browser->assertSeeIn($text,ca_order_status['paid'])
->assertSeeIn(get_order_status['status_text'],ca_order_status['Paid'])
//切换到后台,将状态改为已发货
->driver->switchTo()->window($browser->driver->getWindowHandles()[0]);
$browser->pause(2000)
->press(order_details['pull_btn'])
//修改状态为已支付
//修改状态为发货
->pause(2000)
->click(order_details['paid'])
->click(order_details['Shipped'])
->press(order_details['express_btn'])
//选择快递并填写订单号
->pause(2000);
@ -112,15 +111,20 @@ class AlterOrderStationTest extends DuskTestCase
// 找到第一个子元素并点击它
$secondElement->findElement(WebDriverBy::xpath('./*[1]'))->click();
$browser->type(order_details['order_number'], express['express_code'])
->press(order_details['submit'])
->pause(2000)
//向下滑动找到更新按钮
->scrollIntoView(order_details['alter_btn'])
->pause(2000)
//按下更新按钮
->press(order_details['alter_btn'])
->pause(3000)
//切换到前台,断言是否已发货
->driver->switchTo()->window($browser->driver->getWindowHandles()[1]);
$browser->pause(3000)
->refresh()
->pause(4000);
$text = $browser->text(get_order_status['status_text']);
$browser->assertSeeIn($text,ca_order_status['Shipped'])
->pause(4000)
->assertSeeIn(get_order_status['status_text'],ca_order_status['Shipped'])
//切换到后台,修改状态为已完成
;

View File

@ -66,7 +66,7 @@ class CancelOrderTest extends DuskTestCase
$order_num =$elements[15]->getText();
//打印订单号
echo $order_num;
$browser->clickLink(checkout['view_order'])
$browser->click(checkout['view_order'])
//进入后台,修改订单状态为已取消
->driver->switchTo()->window($browser->driver->getWindowHandles()[0]);
//点击订单管理按钮

View File

@ -44,7 +44,7 @@ class CloseVisiterCheckoutTest extends DuskTestCase
//点击结游客结账 禁用
->press(system_set['close_visitor_checkout'])
//点击保存
->press(common['save_btn'])
->press(system_common['save_btn'])
->pause(2000)
//去往前台验证
->click(admin_top['root'])

View File

@ -28,7 +28,7 @@ require_once(dirname(__FILE__) . '/../../data/admin/cre_categories_page.php');
//增加商品分类
class CreateCategoriesTest extends DuskTestCase
{
public function testCancelOrder()
public function testCreateCategories()
{
$this->browse(function (Browser $browser)
{
@ -42,7 +42,7 @@ class CreateCategoriesTest extends DuskTestCase
->click(admin_top['mg_product'])
//点击商品分类
->click(products_left['product_cate'])
->pause(2000)
->pause(5000)
//点击创建分类按钮
->press(product_cla['cre_cate_btn'])
//填写分类信息

View File

@ -44,7 +44,7 @@ class OpenVisiterCheckoutTest extends DuskTestCase
//点击结游客结账 启用
->press(system_set['open_visitor_checkout'])
//点击保存
->press(common['save_btn'])
->press(system_common['save_btn'])
->pause(2000)
//去往前台验证
->click(admin_top['root'])

View File

@ -0,0 +1,75 @@
<?php
namespace Tests\Browser;
namespace App\Http\Controllers;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
use Facebook\WebDriver\WebDriverBy;
use App\Http\Controllers\By;
use function PHPUnit\Framework\assertNotEquals;
require_once(dirname(__FILE__) . '/../../data/catalog/login.php');
require_once(dirname(__FILE__) . '/../../data/catalog/login_page.php');
require_once(dirname(__FILE__) . '/../../data/catalog/account_page.php');
require_once(dirname(__FILE__) . '/../../data/catalog/product_1.php');
require_once(dirname(__FILE__) . '/../../data/catalog/index_page.php');
require_once(dirname(__FILE__) . '/../../data/catalog/checkout_page.php');
require_once(dirname(__FILE__) . '/../../data/catalog/order_page.php');
require_once(dirname(__FILE__) . '/../../data/admin/login.php');
require_once(dirname(__FILE__) . '/../../data/admin/login_page.php');
require_once(dirname(__FILE__) . '/../../data/admin/order_page.php');
require_once(dirname(__FILE__) . '/../../data/admin/admin_page.php');
require_once(dirname(__FILE__) . '/../../data/admin/express.php');
require_once(dirname(__FILE__) . '/../../data/admin/cre_product.php');
require_once(dirname(__FILE__) . '/../../data/admin/product_page.php');
require_once(dirname(__FILE__) . '/../../data/admin/cre_product_page.php');
////库存不足时下单
class UnderstockOrderTest extends DuskTestCase
{
public function testUnderstockOrder()
{
$this->browse(function (Browser $browser)
{
$browser->visit(admin_login['login_url'])
//登录后台
->type(admin_login['login_email'], admin_true_login['email'])
->type(admin_login['login_pwd'], admin_true_login['password'])
->press(admin_login['login_btn'])
->pause(2000)
//修改商品库存为5
->click(admin_top['mg_product']);
//获取商品名
$product1_text=$browser->text(products_top['get_name']);
echo $product1_text;
//点击编辑商品
$browser->press(products_top['edit_product'])
//修改商品库存为5
->type(product_top['quantity'], alter_product['low_quantity'])
//5.点击保存
->press(product_top['save_btn'])
->pause(3000)
//去往前台下单
->clickLink($product1_text)
->pause(2000)
->driver->switchTo()->window($browser->driver->getWindowHandles()[1]);
//输入库存
$browser->pause(2000)
->type(product['quantity'], alter_product['low_quantity'])
//在库存基础上数量+1 quantity_up
->click(product['quantity_up'])
//4.点击购买按钮
->press(product['product_1'])
->pause(2000)
//断言 understock_assert
->assertVisible(product['understock_assert'])
;
});
}
}

View File

@ -7,6 +7,8 @@ use Tests\DuskTestCase;
require_once(dirname(__FILE__) . '/../../data/catalog/login.php');
require_once(dirname(__FILE__) . '/../../data/catalog/login_page.php');
require_once(dirname(__FILE__) . '/../../data/catalog/account_page.php');
class LoginTest extends DuskTestCase
{
@ -87,7 +89,7 @@ class LoginTest extends DuskTestCase
->type(login['login_pwd'], true_login['password'])
->press(login['login_btn'])
->pause(5000)
->assertUrlIs(account['url']);
->assertPathIs(account['url']);
});
}
}