我的第二个Python+Appium脚本之APP添加商品
来源:互联网 发布:软件授权码商城 编辑:程序博客网 时间:2024/05/17 08:35
#coding:utf-8from appium import webdriverimport timeimport unittestimport osimport HTMLTestRunnerfrom selenium.webdriver.support.ui import WebDriverWaitclass LoginTest(unittest.TestCase): def setUp(self): desired_caps={} desired_caps['platformName'] = 'Android' desired_caps['deviceName'] = 'D1CGAPE6C2902581' desired_caps['platformVersion'] = '7.1.1' desired_caps['appPackage'] = 'appPackage' desired_caps['appActivity'] = 'appActivity' desired_caps['noReset'] = True desired_caps['resetKeyboard'] = True desired_caps['unicodeKeyboard'] = True self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps) def test_login(self): driver = self.driver # 获得机器屏幕大小x,y def getSize(): x = driver.get_window_size()['width'] y = driver.get_window_size()['height'] return (x, y) # 屏幕向上滑动 def swipeUp(t): l = getSize() x1 = int(l[0] * 0.5) # x坐标 y1 = int(l[1] * 0.75) # 起始y坐标 y2 = int(l[1] * 0.25) # 终点y坐标 driver.swipe(x1, y1, x1, y2, t) # 跳转到登录界面清空账号输入框并输入用户名 driver.find_element_by_id('et_account').clear() driver.find_element_by_id('et_account').set_value('18912345678') # 清空密码输入框并输入密码 driver.find_element_by_id('et_password').clear() driver.find_element_by_id('et_password').set_value('123456') ac1 = driver.current_activity # 点击登录按钮 driver.find_element_by_id('bt_login').click() time.sleep(5) # 点击商品管理模块 driver.find_element_by_xpath("//*[@class='android.widget.RelativeLayout'][1]").click() #点击添加新商品按钮 driver.find_element_by_id('tv_add_goods').click() #填写商品相关信息 #添加商品图片 driver.find_element_by_id('item_add').click() driver.find_element_by_id('checkmark').click() driver.find_element_by_id('commit').click() time.sleep(2) # 添加商品名称 driver.find_element_by_id('et_add_new_goods_name').click() driver.find_element_by_id('et_add_new_goods_name').set_value('goods') time.sleep(2) #添加商品描述文字 driver.find_element_by_id('tv_add_new_goods_desc').click() driver.find_element_by_id('et_good_desc').set_value('description') driver.hide_keyboard() #添加商品描述图片 driver.find_element_by_id('tv_add_pic').click() driver.find_element_by_id('checkmark').click() driver.find_element_by_id('commit').click() driver.find_element_by_id('tv_complete').click() time.sleep(2) #选择商品分类 driver.find_element_by_id('tv_add_new_goods_type').click() driver.find_element_by_id('item_tv_name').click() #输入商品型号 driver.find_element_by_id('item_model').set_value('size') driver.hide_keyboard() time.sleep(2) driver.find_element_by_id('item_now').set_value('9.9') driver.hide_keyboard() time.sleep(2) swipeUp(1000) #库存输入框没有显示,上滑界面将库存显示出来 driver.find_element_by_id('item_stock').click() driver.find_element_by_id('item_stock').set_value(u'10') #点击保存按钮 driver.find_element_by_id('tv_wait_set').click() time.sleep(2) def tearDown(self): self.driver.quit()if __name__ =='__main__': unittest.main()
阅读全文
0 0
- 我的第二个Python+Appium脚本之APP添加商品
- 我的第一个Python+Appium脚本之APP登录脚本
- 2.appium-通过appium启动我的第一个手机app
- 我的第一个python脚本
- 我的第一个python爬虫脚本
- appium 下 python 脚本自动化测试iOS APP 实例
- [Android测试] AS+Appium+Java+Win 自动化测试之七: 写脚本测试自己的app
- appium第一个脚本
- 我的Appium学习之路
- Appium基础篇3-第一个appium自动化脚本之自动安装apk包到手机
- appium的运行的第一个脚本(四)
- appium+python自动化实践之添加移动端logcat日志
- Appium+python自动化-启动app
- appium+Python运行脚本环境
- Appium Python app 启动各参数的意思
- appium的python脚本编写前准备(三)
- 我的第二个blog
- 我的第二个HelloWrold.
- 傅里叶分析学习
- 11111111111
- 第四周——自建单链表算法库
- 数据结构实验之栈与队列九:行编辑器
- 第11周项目4-利用遍历思想求解图问题
- 我的第二个Python+Appium脚本之APP添加商品
- Linux reset framework
- 厉害了!穿越体寄语集体出街 超萌超大字体引年轻族驻足流连
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- 如何连接同事的电脑数据库
- 第四周项目3
- C/C++ 第八周串和数组 (一)稀疏矩阵的三元组表示的实现及应用 项目4—(1)
- MFC 错误:没有与参数列表匹配的 重载函数
- this的四种用法