Commit b9927b88 authored by YuShijiaCode's avatar YuShijiaCode

add cases for product

parent bb05bc2e
......@@ -48,6 +48,16 @@ class MerchantPlanPage {
confirm_delete_btn = '//*[@class="ant-popconfirm-buttons"]/button'
plan_list_table = '//*[@class="ant-table-tbody"]'
new_product_btn = '(//*[@class="ant-tabs-nav-add"]/span[@aria-label="plus"])[1]'
product_name = '//*[@id="productName"]'
product_description = '//*[@id="description"]'
product_detail_OK = '//*[text()="OK"]'
product_delete_OK = '//*[text()="OK"]'
product_edit_OK = '//*[text()="OK"]'
product_edit_btn = '(//*[@aria-label=\'edit\'])[1]'
selectCurrency = async function (driver, currency = "EUR"){
console.log("selectCurrency: " , currency);
let currency_list = {
......@@ -141,6 +151,29 @@ class MerchantPlanPage {
await baseStep.wait(driver, 1000);
}
selectProduct = async function (driver, name){
console.log("select product: " + name);
await baseStep.click(driver, "//*[text()='"+name+"']");
await baseStep.wait(driver, 1000);
}
deleteProduct = async function (driver, name){
console.log("delete product: " + name);
await baseStep.click(driver, "//*[text()='"+name+"']/following-sibling::button");
await baseStep.wait(driver, 1000);
}
clickNewPlanBtn = async function(driver){
let btns = await driver.findElements(By.xpath(this.new_plan_btn));
for(let btn of btns){
console.log("-------", btn);
if (await btn.isDisplayed()){
await btn.click();
break;
}
}
}
}
module.exports = new MerchantPlanPage();
......@@ -39,7 +39,9 @@ class MerchantUserListPage {
current_plan = "//*[text()='Plan']/following-sibling::div[1]"
current_plan_des = "(//*[text()='Plan Description'])[1]/following-sibling::div[1]"
current_status= "(//*[text()='Status'])[3]//following-sibling::div[1]/span"
plan_name = '(//*[text()="Plan"]/following-sibling::div[1])'
sub_status = '(//*[text()="Status"]/following-sibling::div[1]/span[1])'
plan_search_list = '//*[text()="Assign subscription"]/../following-sibling::div//input[@type="search"]/..'
......@@ -82,6 +84,46 @@ class MerchantUserListPage {
await baseStep.wait(driver, 1000);
}
selectProduct = async function (driver, name){
console.log("select product: " + name);
await baseStep.click(driver, "//*[text()='"+name+"']");
await baseStep.wait(driver, 1000);
}
checkRecordHistoryList = async function(driver, product="", plan="", status= "" ,record = 1){
await baseStep.waitUntilElement(driver, "//*[@class='ant-table-tbody']", 20000);
await baseStep.wait(driver,5000);
let table = await driver.findElement(By.xpath("//*[@class='ant-table-tbody']"));
let rows = await table.findElements({ tagName: 'tr' })
console.log("rows.length: ",rows.length)
let cells = await rows[record].findElements({ tagName: 'td' });
if (product!== ""){
let actual_product= await cells[0].getText()
expect(await actual_product).to.equal(product);
}
if (plan !== ""){
let actual_plan = await cells[1].getText()
expect(await actual_plan).to.equal(plan);
}
if (status !== ""){
let actual_status= await cells[4].getText()
expect(actual_status).to.equal(status);
}
}
clickAssignBtn = async function(driver){
let btns = await driver.findElements(By.xpath(this.assign_sub_btn));
for(let btn of btns){
console.log("-------", btn);
if (await btn.isDisplayed()){
await btn.click();
break;
}
}
}
}
......
const baseStep = require("../../CommonStep/Web/Web_Common_Step");
const webdriver = require('selenium-webdriver');
const {expect} = require("chai");
const By = webdriver.By;
class UserMySubPage {
menu_my_subscription= '//*[@class="ant-menu-title-content" and text()="My Subscription"]'
sub_status = '//*[text()="Status"]/following-sibling::div[1]/span'
plan_name = '(//*[text()="Plan"]/following-sibling::div[1])'
sub_status = '(//*[text()="Status"]/following-sibling::div[1]/span[1])'
cancel_sub_button = '//span[text()="CANCEL"]'
cancel_confirm_button = '//span[text()="Yes, Cancel it"]'
go_to_choose_one = '//*[text()="Go to choose one"]'
selectProduct = async function (driver, name){
console.log("select product: " + name);
await baseStep.click(driver, "//*[text()='"+name+"']");
await baseStep.wait(driver, 1000);
}
checkRecordHistoryList = async function(driver, product="", plan="", status= "" ,record = 1){
await baseStep.waitUntilElement(driver, "//*[@class='ant-table-tbody']", 20000);
await baseStep.wait(driver,5000);
let table = await driver.findElement(By.xpath("//*[@class='ant-table-tbody']"));
let rows = await table.findElements({ tagName: 'tr' })
console.log("rows.length: ",rows.length)
//*[@id="root"]/div/div/main/div/div/div[1]/div/div/div/div/div[2]/table/tbody/tr[2]/td[3]/div/span
let cells = await rows[record].findElements({ tagName: 'td' });
if (product!== ""){
let actual_product= await cells[0].getText()
// let amount = await driver.findElement(By.xpath("//*[@id=\"root\"]/div/div/main/div/div/div[1]/div/div/div/div/div[2]/table/tbody/tr["+(record+1)+"]/td[3]/div/span"))
expect(await actual_product).to.equal(product);
}
if (plan !== ""){
let actual_plan = await cells[1].getText()
// let actualStatus = await driver.findElement(By.xpath("//*[@id=\"root\"]/div/div/main/div/div/div[1]/div/div/div/div/div[2]/table/tbody/tr["+(record+1)+"]/td[4]/span"))
expect(await actual_plan).to.equal(plan);
}
if (status !== ""){
let actual_status= await cells[4].getText()
expect(actual_status).to.equal(status);
}
}
isProductSelected = async function(driver, productName){
let element = await driver.findElement(By.xpath("//*[text()='"+productName+"']"));
return await element.getAttribute('aria-selected');
}
}
module.exports = new UserMySubPage();
......@@ -43,6 +43,11 @@ class UserPlanPage {
}
selectProduct = async function (driver, name){
console.log("select product: " + name);
await baseStep.click(driver, "//*[text()='"+name+"']");
await baseStep.wait(driver, 1000);
}
......
This diff is collapsed.
......@@ -14,7 +14,6 @@ const ApiReq = new API_Object("https://api.unibee.top");
const addContext = require('mochawesome/addContext');
const {expect} = require("chai");
const {wait} = require("../../../CommonStep/Web/Web_Common_Step");
let request;
let response;
let timeStamp = new Date();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment