微信小程序 - 18570580798/study GitHub Wiki

BIZ Open MC [Arguments] ${version}=${EMPTY} ${publisher}=${EMPTY} @{FAILED_PRODUCT_CODE} Create List Set Global Variable @{FAILED_PRODUCT_CODE} ${store_name} Get Environment Variable STORE_NAME ${version} Get Environment Variable VERSION ${publisher} WM Get System Variable PUBLISHER Should Not Be Empty ${store_name} Should Not Be Empty ${version} Set Global Variable ${store_name} ELE Open WX Program Run Keyword If '${version}'=='线上版' WM Click Element //android.widget.LinearLayout/*[last()]/android.widget.TextView[contains(@text,"沃尔玛")] ... ELSE IF '${version}'=='开发版' or '${version}'=='体验版' ELE Select Development Version Update ${version} ${publisher} Wait Until Page Contains element xpath=//android.widget.FrameLayout[contains(@resource-id,"com.tencent.mm")] 20 sleep 2 ELE Get Location ELE Store Location Is Selected 选择门店 ${CITY} ${store_name} sleep 2 ELE Is Expect Store ${CITY} ${store_name} AST Cart Store Name ${store_name}

BIZ E-Invoice [Arguments] ${individuals} ${units} @{list} [Documentation] 默认${individuals}=${True} WM Click Element class=cart-invoice-arrow Select Window By Name2 invoiceSetting sleep 2 WM Click Element //wx-button[text()="电子发票"] @{invoices_title} Create List ${individuals} ${units} @{checkbox_locator} Create List //wx-radio[@value="Individuals"] //wx-radio[@value="Units"] : FOR ${cb_status} ${locator} IN ZIP ${invoices_title} ${checkbox_locator} \ Run Keyword If '${cb_status}'=='${True}' Run Keywords WM Click Element ${locator} \ ... AND Exit For Loop ${individuals_class}= Get Element Attribute //wx-radio[@value="Individuals"]/div/div class ${units_class}= Get Element Attribute //wx-radio[@value="Units"]/div/div class ${is_checked}= Run Keyword And Return Status Should Contain ${individuals_class} checked Run Keyword If '${is_checked}'=='True' ELE Fill Invoices Individuals Info @{list} ${is_checked}= Run Keyword And Return Status Should Contain ${units_class} checked Run Keyword If '${is_checked}'=='True' ELE Fill Invoices Units Info @{list} Click Element class=submit-button Select Window By Name2 cart sleep 2

ELE Log Contests ${contexts} get_contexts ${current_context} get_current_context log ${contexts} log ${current_context}

ELE Open WX Program sleep 2 ${device_name} Get Environment Variable DEVICE_NAME ${platform_version} Get Environment Variable PLATFORM_VERSION ${remote_server} Get Environment Variable ROBOT_APPIUM_REMOTE_SERVER Should Not Be Empty ${device_name} Should Not Be Empty ${platform_version} Should Not Be Empty ${remote_server} ${androidProcess}= Create Dictionary androidProcess=com.tencent.mm:appbrand0 Open Application ${remote_server}/wd/hub platformName=Android platformVersion=${platform_version} deviceName=${device_name} appPackage=com.tencent.mm appActivity=com.tencent.mm.ui.LauncherUI ... chromeOptions=${androidProcess} unicodeKeyboard=True resetKeyboard=True noReset=True recreateChromeDriverSessions=True #automationName=uiautomator2 WM Click Element //android.widget.TextView[@text="发现"] 30s WM Swipe Down And Click Element In Native //android.widget.TextView[@text="小程序"]

ELE Select Version From Develop Assistant [Arguments] ${version} ${publisher} WM Click Element //android.widget.TextView[@text="小程序开发助手"] sleep 5 Switch To Context ${MC_PID.webview} sleep 2 Select MP Window By Route Name index sleep 2 Run Keyword If '${version}'=='开发版' ELE Select Development Version ${publisher} Run Keyword If '${version}'=='体验版' WM Click Element //span[contains(text(),"${version}")]/../../.. sleep 3 Switch To Context ${MC_PID.native} sleep 2 Close Application sleep 2

ELE Select Development Version [Arguments] ${publisher} [Documentation] 在小程序开发助手里面选择发布的QA版本 ${status}= Run Keyword And Return Status Wait Until Page Contains Element //span[text()="查看全部"]/../.. Run Keyword If '${status}'=='True' Click Element //span[text()="查看全部"]/../.. sleep 2 WM Swipe Down And Click Element In Webview //span[contains(text(),"${publisher}")]/../..

ELE Select Development Version Update [Arguments] ${version} ${publisher} WM Click Element //android.widget.TextView[@text="${version}"]/.. sleep 5 ${status} Run Keyword And Return Status Wait Until Page Contains element //android.widget.TextView[@text="${version}"]/.. 10 Run Keyword If '${status}'=='True' Run Keywords ELE Select Version From Develop Assistant ${version} ${publisher} ... AND sleep 5 ... AND ELE Open WX Program ... AND WM Click Element //android.widget.TextView[@text="${version}"]/..

ELE WX Payment [Arguments] ${text} [Documentation] 微信支付 ${passwd} Get Environment Variable PASSWD Should Not Be Empty ${passwd} sleep 3 Switch To Context ${MC_PID.native} Wait Until Element Is Visible //android.widget.TextView[@text="请输入支付密码"] 30 Run Keyword If '${text}'=='支付' Run Keywords WM Click Element //android.widget.TextView[@text="请输入支付密码"]/../../android.widget.LinearLayout[1]/android.widget.RelativeLayout[2] ... AND ELE Input String ${passwd} ... AND sleep 1 ... AND WM Click Element //android.widget.Button[@text="完成"] ... AND sleep 3 ... AND Switch To Context ${MC_PID.webview} ... AND sleep 2 ... AND Select MP Window By Route Name paymentResult ... AND sleep 2 Run Keyword If '${text}'=='不支付' Run Keywords ELE Go Back ... AND Switch To Context ${MC_PID.webview} ... AND sleep 2 ... AND Select MP Window By Route Name orderDetail ... AND sleep 2

ELE Get Now Time ${yyyy} ${mm} ${dd} Get Time year,month,day ${now_time} Set Variable ${yyyy}/${mm}/${dd} [Return] ${now_time}

ELE Add Product [Documentation] 添加商品条码 ${product_code_list} Get Environment Variable PRODUCT_CODE Should Not Be Empty ${product_code_list} @{product_code_list} Set Variable ${product_code_list.split(',')} ${len} Get Length ${product_code_list} : FOR ${i} IN RANGE ${len} \ ${len2} Get Length ${product_code_list} \ ${index} Evaluate random.randint(0,int(${len2})-1) random \ ${product_code} Set Variable @{product_code_list}[${index}] \ ELE Input String ${product_code} \ Click Element xpath=//wx-button[text()="添加"] \ Switch To Context ${MC_PID.native} \ ${status}= Run Keyword And Return Status Wait Until Page Contains Element //android.widget.TextView[@text="提示"] 5 \ sleep 2 \ Switch To Context ${MC_PID.webview} \ sleep 2 \ Run Keyword If '${status}'=='False' Run Keywords sleep 2 \ ... AND Select MP Window By Route Name cart \ ... AND sleep 2 \ ... AND Exit For Loop \ Run Keyword If '${status}'=='True' Run Keywords ELE Invalid code \ ... AND Remove Values From List ${product_code_list} ${product_code} \ ... AND Append To List ${FAILED_PRODUCT_CODE} ${product_code}

ELE Delete Text [Arguments] ${context} [Documentation] 删除输入框内容 ${len} Get Length ${context} : FOR ${i} IN RANGE int(${len})+1 \ Press Keycode 67

ELE Get Prodcut Detail @{ele} Get Webelements //wx-text[@class="cart-item-desc"] ${len} Get Length ${ele} : FOR ${i} IN RANGE ${len} \ ${cart_goods_name}= Get Text //wx-view[@data-index="${i}"]//wx-text[@class="cart-item-desc"]/span[2] \ ${get_cart_goods_price}= Get Text //wx-view[@data-index="${i}"]//wx-text[@class="cart-item-price"]/span[2] \ ${cart_goods_price} Set Variable ${get_cart_goods_price[2:]} \ ${status} Run Keyword And Return Status Element Should Be Visible //wx-view[@data-index="${i}"]//wx-input[@class="cart-item-count-input"] \ ${get_cart_goods_quantity}= Run Keyword If '${status}'=='True' Get Element Attribute //wx-view[@data-index="${i}"]//wx-input[@class="cart-item-count-input"] value \ ... ELSE Set Variable 1 \ &{goods_dic} Create Dictionary name=${cart_goods_name} price=${cart_goods_price} quantity=${get_cart_goods_quantity} \ Append To List ${cart_goods_list} ${goods_dic} [Return] @{cart_goods_list}

ELE Get Shopping Bag Detail ${status1} Run Keyword And Return Status Page Should Contain Element //div[@class="wx-scroll-view"]//wx-view[@class="shopping-bag-item"] ${status2} Run Keyword And Return Status Page Should Contain Element //div[@class="wx-scroll-view"]//wx-view[@class="shopping-bag-one-item"] ${cart_goods_list}= Run Keyword If '${status1}'=='True' ELE Get More Shopping Bag Detail ... ELSE IF '${status2}'=='True' ELE Get One Shopping Bag Detail [Return] ${cart_goods_list}

ELE Get More Shopping Bag Detail ${locator} Set Variable //div[@class="wx-scroll-view"]//wx-view[@class="shopping-bag-item"] @{ele} Get Webelements //div[@class="wx-scroll-view"]//wx-view[@class="shopping-bag-item"] ${len} Get Length ${ele} : FOR ${i} IN RANGE ${len} \ ${index} Evaluate int(${i})+1 \ ${shopping_bag_quantity} Get Text ${locator}[${index}]//wx-text[@class="shopping-bag-item-count"]/span[2] \ ${shopping_bag} Get Text ${locator}[${index}]//wx-text[@class="shopping-bag-item-desc"]/span[2] \ Comment @{shopping_bag} Set Variable ${shopping_bag.split('¥')} \ ${shopping_bag_name} Set Variable ${shopping_bag[:5]} \ ${shopping_bag_price} Set Variable ${shopping_bag[-4:]} \ &{shopping_bag} Create Dictionary name=${shopping_bag_name} price=${shopping_bag_price} quantity=${shopping_bag_quantity} \ Append To List ${cart_goods_list} ${shopping_bag} [Return] ${cart_goods_list}

ELE Get One Shopping Bag Detail ${locator} Set Variable //div[@class="wx-scroll-view"]//wx-view[@class="shopping-bag-one-item"] ${shopping_bag_quantity} Get Text ${locator}//wx-text[@class="shopping-bag-one-count"]/span[2] ${shopping_bag_name} Get Text ${locator}//wx-text[@class="shopping-bag-one-desc"]/span[2] ${get_shopping_bag_price} Get Text ${locator}//wx-text[@class="shopping-bag-one-price"]/span[2] ${shopping_bag_price} Set Variable ${get_shopping_bag_price[1:]} &{shopping_bag} Create Dictionary name=${shopping_bag_name} price=${shopping_bag_price} quantity=${shopping_bag_quantity} Append To List ${cart_goods_list} ${shopping_bag} [Return] ${cart_goods_list}

ELE Get Cart Detail [Documentation] 获取购物车页面详情信息 \ 如商品名称,商品价格,商品数量,购物袋信息,合计金额,优惠金额 @{cart_goods_list} Create List Set Global Variable @{cart_goods_list} Wait Until Element Is Visible class=order-total-right ${status} Run Keyword And Return Status Page Should Contain Element //wx-view[@data-index="0"] ${cart_goods_list}= Run Keyword If '${status}'=='True' ELE Get Prodcut Detail ${cart_goods_list}= ELE Get Shopping Bag Detail ${get_cart_total_price}= Get Text //wx-text[@class="order-amount-text"]/span[2] ${get_cart_discount}= Get Text //wx-view[@class="cart-discount"]//span[2] ${cart_total_price} Set Variable ${get_cart_total_price[2:]} ${cart_discount} Set Variable ${get_cart_discount[6:]} &{cart_detail} Create Dictionary item=${cart_goods_list} cart_total_price=${cart_total_price} cart_discount=${cart_discount} Set Global Variable &{cart_detail} [Return] &{cart_detail}

ELE Paid Order Detail Button [Arguments] ${text} [Documentation] 已支付订单详情页面,点击三个不同的按钮走的分支; 查看购买记录,继续购物,扫码出场 Comment WM Click Element //wx-view[text()="${text}"] Run Keyword If '${text}'=='查看购买记录' Run Keywords WM Click Element //wx-view[text()="${text}"] ... AND sleep 2 ... AND Select MP Window By Route Name orderList ... AND Wait Until Element Is Visible //wx-view[@data-index="0"] 10 ... AND ELE Go Back ... ELSE IF '${text}'=='继续购物' Run Keywords WM Click Element //wx-view[text()="${text}"] ... AND sleep 2 ... AND Select MP Window By Route Name cart ... AND Wait Until Element Is Visible //wx-text/span[text()="如果当前商场不正确,将无法正常结算,点击顶栏可切换"][2] 20 ... ELSE IF '${text}'=='扫码出场' Run Keywords WM Click Element //wx-button[text()="${text}"] ... AND ELE Scan Store QR Code

ELE Go Back [Documentation] 返回到购物车页面 sleep 2 Press Keycode 4 sleep 2

ELE Scan Store QR Code [Documentation] 扫描店面二维码 sleep 3 Switch To Context ${MC_PID.native} sleep 1 WM Click Element //android.widget.ImageButton[contains(@content-desc,"更多")] WM Click Element //android.widget.TextView[@text="从相册选取二维码"] WM Click Element //android.widget.TextView[@text="所有图片"] #点击所有图片 WM Click Element //android.widget.TextView[@text="WeiXin"]/../.. #选择微信图片二维码 WM Click Element //android.widget.ImageView[contains(@content-desc,"图片")] #选择二维码 sleep 3 Switch To Context ${MC_PID.webview} sleep 3 ${route}= execute_javascript return window.route Wait Until Element Is Visible //wx-view[@class="exitToastContent"] 20 ${ret} Run Keyword And Return Status Wait Until Element Is Visible //wx-view[text()="确定"] 5 Run Keyword If '${ret}'=='True' WM Click Element //wx-view[text()="确定"] WM Click Element //wx-view[text()="去首页"] sleep 2 Select MP Window By Route Name cart sleep 3

BIZ Open MC [Arguments] ${version}=${EMPTY} ${publisher}=${EMPTY} @{FAILED_PRODUCT_CODE} Create List Set Global Variable @{FAILED_PRODUCT_CODE} ${store_name} Get Environment Variable STORE_NAME ${version} Get Environment Variable VERSION ${publisher} WM Get System Variable PUBLISHER Should Not Be Empty ${store_name} Should Not Be Empty ${version} Set Global Variable ${store_name} ELE Open WX Program Run Keyword If '${version}'=='线上版' WM Click Element //android.widget.LinearLayout/*[last()]/android.widget.TextView[contains(@text,"沃尔玛")] ... ELSE IF '${version}'=='开发版' or '${version}'=='体验版' ELE Select Development Version Update ${version} ${publisher} Wait Until Page Contains element xpath=//android.widget.FrameLayout[contains(@resource-id,"com.tencent.mm")] 20 sleep 2 ELE Get Location ELE Store Location Is Selected 选择门店 ${CITY} ${store_name} sleep 2 ELE Is Expect Store ${CITY} ${store_name} AST Cart Store Name ${store_name}

BIZ Open MC Direct [Arguments] ${version}=${EMPTY} sleep 2 ELE Open WX Program ${version} Get Environment Variable VERSION Should Not Be Empty ${version} Run Keyword If '${version}'=='开发版' WM Click Element //android.widget.TextView[@text="开发版"]/.. Run Keyword If '${version}'=='线上版' WM Click Element //android.widget.LinearLayout/*[last()]/android.widget.TextView[contains(@text,"沃尔玛")] Run Keyword If '${version}'=='体验版' WM Click Element //android.widget.TextView[@text="体验版"]/.. Wait Until Page Contains element xpath=//android.widget.FrameLayout[contains(@resource-id,"com.tencent.mm")] 20 ${status}= Run Keyword And Return Status Wait Until Page Contains Element //android.widget.TextView[contains(@text,"是否切换门店?")] 5 Run Keyword If '${status}'=='True' WM Click Element //android.widget.Button[@text="暂不切换"] sleep 2 Switch To Context ${MC_PID.webview} sleep 2 Select MP Window By Route Name cart sleep 2

BIZ Get Latest MC Version [Arguments] ${version} ${publisher} [Documentation] 从小程序开发助手进去得到最新版本 sleep 3 ELE Open WX Program WM Click Element //android.widget.TextView[@text="小程序开发助手"] sleep 3 Switch To Context ${MC_PID.webview} sleep 2 Select MP Window By Route Name index sleep 2 Run Keyword If '${version}'=='开发版本' ELE Select Development Version ${publisher} Run Keyword If '${version}'=='体验版本' ELE Select Production Or Stage Version ${version} sleep 5 ELE Log Contests Switch To Context ${MC_PID.native} Wait Until Element Is Visible //android.widget.TextView[@text="沃尔玛扫玛购"] 10 ELE Get Location ELE Store Location Is Selected 选择门店 ${CITY} ${store_name} sleep 2 Close All Applications sleep 3

BIZ Input Code [Arguments] ${code}=${EMpty} [Documentation] 输入条码添加商品 ${status}= Run Keyword And Return Status Element Should Be Visible xpath=//wx-view[text()="手工输入条形码"][1] Run Keyword If '${status}'=='True' Click Element xpath=//wx-view[text()="手工输入条形码"][1] ... ELSE Click Element //wx-image[@class="bottom-enter-btn"] sleep 2 Select MP Window By Route Name barcodeEnter ELE Input String ${code} Click Element xpath=//wx-button[text()="添加"] sleep 2 Select MP Window By Route Name cart sleep 2

AST Order Goods And Shopping Bag Detail [Arguments] ${cart_detail} @{order_detail_list} Create List Set Suite Variable @{order_detail_list} @{ele} Get Webelements //wx-view[@class="order-detail-item-desc-view"] ${len} Get Length ${ele} : FOR ${i} IN RANGE ${len} \ ${index} Evaluate int(${i})+1 \ ${order_detail_name} Get Text //wx-view[${index}][@class="order-detail-item-desc-view"]//wx-text[@class="order-detail-item-desc"]/span[2] \ ${get_order_detail_price} Get Text //wx-view[${index}][@class="order-detail-item-desc-view"]/following-sibling::wx-view//wx-text[@class="order-detail-item-price"]/span[2] \ ${get_order_detail_quantity} Get Text //wx-view[${index}][@class="order-detail-item-desc-view"]/following-sibling::wx-view//wx-view[@class="order-detail-item-count"]//span[2] \ ${order_detail_price} Set Variable ${get_order_detail_price[1:]} \ ${order_detail_quantity} Set Variable ${get_order_detail_quantity[1:]} \ &{order_detail} Create Dictionary order_detail_name=${order_detail_name} order_detail_price=${order_detail_price} order_detail_quantity=${order_detail_quantity} \ Append To List ${order_detail_list} ${order_detail} ${len} Get Length ${cart_detail.item} ${j} Set Variable 0 : FOR ${i} IN RANGE ${len} \ Run Keyword If '${cart_detail.item[${i}].quantity}'>'0' Run Keywords Should Be Equal ${cart_detail.item[${i}].name} ${order_detail_list[${j}].order_detail_name} \ ... AND Should Be Equal ${cart_detail.item[${i}].price} ${order_detail_list[${j}].order_detail_price} \ ... AND Should Be Equal ${cart_detail.item[${i}].quantity} ${order_detail_list[${j}].order_detail_quantity} \ ... ELSE IF '${cart_detail.item[${i}].quantity}'=='0' Continue For Loop \ ${j} Evaluate ${j}+1

AST Paid Order Detail [Arguments] ${store} ${status} ${total_quantity} ${payment_type} ${cart_detail} ${invoice_type} ... @{list} [Documentation] 已支付订单详情页面信息校验; 如 ${status_amount}=已付款¥0.12 ; ${store}=华侨城店 ;${status}=完成 ; ${quantity}=1件; ${total_amount}=¥0.12 ; ${payment_type}=微信支付 ; ${goods_name}=活鲫鱼/份 ;${goods_price}=¥0.12;${goods_quantity}=x1; ${order_amount}=0.12; ${order_discount}=0.00; ${exit_time}=2018/01/25 19:00:01;${invoice_type}=电子发票;@{list}=电子发票生成中... Wait Until Element Is Visible //wx-view[@class="status-wrap"] 10 ${get_status_amount}= Get Text //wx-view[@class="status-wrap"]//span[2] Should Contain Any ${get_status_amount} 已付款 ${cart_detail.cart_total_price} ${now_time}= ELE Get Now Time ${get_time}= Get Text //wx-view[contains(text(),"付款时间")] ${paid_time} Set Variable ${get_time[5:]} Should Contain ${get_time} ${now_time} Execute Javascript document.documentElement.scrollTop=document.body.scrollHeight-document.documentElement.clientHeight AST Element Is Exist ${store} AST Element Is Exist ${status} Comment Run Keyword If '${status}'=='已支付' AST Paid Order Num ... ELSE IF '${status}'=='完成' AST Complete Order Num ${order_num} ${get_order_num}= Get Text //span[text()="订 单 号:"]/../following-sibling::wx-text/span[2] ${order_num} Set Variable ${get_order_num} log ${get_order_num} ${len}= Get Length ${get_order_num} Should Be Equal As Integers ${len} 20 ${get_quantity}= Get Text //span[text()="商品总数:"]/../following-sibling::wx-text/span[2] ${get_total_amount}= Get Text //span[text()="合计金额:"]/../following-sibling::wx-text/span[2] ${get_payment_type}= Get Text //span[text()="付款方式:"]/../following-sibling::wx-text/span[2] Should Be Equal As Strings ${get_quantity} ${total_quantity} Should Be Equal As Strings ${get_total_amount[1:]} ${cart_detail.cart_total_price} Should Be Equal As Strings ${get_payment_type} ${payment_type} ${get_invoice_num}= Get Text //span[text()="购物小票:"]/../following-sibling::wx-text/span[2] ${len}= Get Length ${get_invoice_num} Should Be True 6<${len}<21 ${invoice_num} Set Variable ${get_invoice_num} &{paid_detail} Create Dictionary order_num=${order_num} paid_time=${paid_time} invoice_num=${invoice_num} Set Suite Variable &{paid_detail} Run Keyword If '${invoice_type}'=='电子发票' AST After Order Invoice @{list} ... ELSE IF '${invoice_type}'=='不要发票' or '${invoice_type}'=='纸质发票' Page Should Not Contain Element //span[text()="电子发票:"]/.. 5 Comment @{order_detail_list} Create List Comment Set Suite Variable @{order_detail_list} AST Order Goods And Shopping Bag Detail ${cart_detail} ${get_order_amount}= Get Text //span[text()="订单合计:"]/../preceding-sibling::wx-text/span[2] ${get_order_discount}= Get Text //span[text()="优惠合计:"]/../preceding-sibling::wx-text/span[2] ${order_amount}= Set Variable ${get_order_amount[1:]} ${order_discount}= Set Variable ${get_order_discount[1:]} Should Be Equal ${cart_detail.cart_total_price} ${order_amount} Should Be Equal ${cart_detail.cart_discount} ${order_discount}