def home(self, action: ElementActions):
     action.driver.wait_activity(self.activity, 8, interval=0.3)
     try:
         action.click(self.关闭初始化弹出窗, wait=3)
     except:
         log.info('无弹窗需要关闭,所以不会找到元素 关闭初始化弹出窗')
     action.tap(self.关闭初始化浮窗)
Beispiel #2
0
def check_page(Pages,action: ElementActions):

    #只能检测静态页面,即有固定进入方法的:pageinto

    pagesname_list=get_attrsname(Pages)

    for page_name in pagesname_list:
        page=getattr(Pages,page_name)


        #如果为静态页面时可通过page的跳转方法进入对应页面
        if hasattr(page,'pageinto')==False:
            continue
        else:
            log.info(' ----检测静态页面: {}----'.format(page_name))
            elements_name = get_attrsname(page)
            getattr(page,'pageinto')(action)

            # 对元素进行遍历查询
            for element_name in elements_name:
                element=getattr(page,element_name)
                if isinstance(element,dict):
                    if element.get('dynamic')==False:
                        if element.get('switch')!=None:
                            #如果该元素在当前页面有前置步骤,则执行该前置步骤
                            getattr(page,element.get('switch'))(action)

                        action.is_element_exist(locator=element)
Beispiel #3
0
 def pageinto(self, action: ElementActions):
     action.sleep(0.5).start_activity(self.activity)
     usercenterpage = UserCenterPage()
     # usercenterpage.pageinto(action)
     if action.find_ele(usercenterpage.注册登陆) != None:
         action.click(usercenterpage.注册登陆)
     else:
         log.info('app已是登陆状态,无法进入登陆页')
 def test_slowShot(self,action:ElementActions):
     action.click(HomePage.拍摄按钮)
     action.click(ShotPage.拍摄速度)
     action.click(ShotPage.慢速)
     action.click(ShotPage.拍摄按钮)
     action.sleep(12)
     assert action.is_element_displayed(ShotPage.编辑完成,is_retry=False)
 def test_Upload(self,action:ElementActions):
     action.click(HomePage.拍摄按钮)
     action.click(ShotPage.上传视频)
     action.sleep(2)
     action.click(ShotPage.选择视频)
     action.click(ShotPage.剪切完成)
     action.click(ShotPage.编辑完成)
     assert action.is_text_displayed('Post')
Beispiel #6
0
 def test_login(self, action: ElementActions):
     L.d('test_login')
     account = Steps.get_account()
     action.click(HomePage.登录入口)
     action.text(LoginPage.账户, account[0])
     action.text(LoginPage.密码, account[1])
     action.sleep(1)
     action.click(LoginPage.登录)
     assert action.is_toast_show('欢迎回来')
Beispiel #7
0
    def is_logined(self, action: ElementActions):
        #已登陆时返回True

        if action.find_ele(self.注册登陆, wait=2) != None:
            return False
        else:
            return True
Beispiel #8
0
 def test_login_empty_password(self, action: ElementActions):
     account = Steps.get_account()
     time.sleep(20)
     action.swip_left(3)
     time.sleep(5)
     L.d('test_login_empty_password')
     L.i('账户{0},密码为空'.format(account[0]))
     action.click(HomePage.登录)
     login(account[0], "", action)
     action.sleep(5)
     try:
         assert action.is_text_displayed('密码能为空1')
     except Exception as e:
         action.save_failure_pic(sys._getframe().f_code.co_name)
    def test_musicShot(self,action:ElementActions):
        action.click(HomePage.音乐集合页按钮)

        action.click(MusicCgPage.拍摄按钮)
        action.sleep(3)

        assert action.is_text_displayed('Tap to shoot')
        """
Beispiel #10
0
    def test_home(self, action: ElementActions):

        # up.登录页.login(action,'13550234762','tmhrush2233')

        action.click(p.特卖首页.搜索输入框)

        #因为调用action的大部分公用方法是返回self,所以可以一条语句执行多次不同方法
        action.text(p.分类列表搜索页.搜索输入框,"口红")\
            .click(p.分类列表搜索页.搜索按钮)

        action.click(p.搜索后列表页.第一个商品项)

        #循环下拉,检查是否有对应关键字,找到后终止
        for count in range(20):
            if action.swip_down().is_text_displayed("商品参数"):
                break
        #没有对应关键字抛出错误
        if action.is_text_displayed("口红") == False:
            raise NotFoundTextError

        action.sleep(1)
Beispiel #11
0
    def test_add_poster(self, action: ElementActions):

        action.click(HomePage.关注按钮)
        action.sleep(1)
        action.capture_screen(
            u'关注截图',
            '/Users/zhangweishun/Desktop/appium-lich-master/screenshot/')
Beispiel #12
0
    def test_share(self, action: ElementActions):

        action.click(HomePage.分享按钮)
        action.sleep(1)
        """
        判断是否有文本"share to"
        """
        action.is_text_displayed('Share to')
Beispiel #13
0
    def test_download(self, action: ElementActions):
        action.click(HomePage.下载按钮)
        action.sleep(2)

        # 断言再想想,很难想
        action.capture_screen(
            u'下载截图',
            '/Users/zhangweishun/Desktop/appium-lich-master/screenshot/')
Beispiel #14
0
def login(account, password, action: ElementActions):
    time.sleep(5)
    # action.driver.find_element_by_id('com.shautolinked.car:id/btnLeft').click()

    action.text(LoginPage.用户名, account, clear_first=True)
    action.text(LoginPage.密码, password, clear_first=True)
    action.sleep(1)
    action.click(LoginPage.登录)
def browseproduct(action: ElementActions, key='专场', position=0):
    p.搜索后列表页.pageinto(action, key)
    # 点击对应position的商品
    action.sleep(1).click_ele(
        action.find_ele(p.搜索后列表页.商品项标题s, is_Multiple=True)[position]).sleep(2)

    productname_ele = None
    for index in range(10):
        action.swip_down()
        tmpele = action.find_ele(p.商品详情页.商品参数列表)
        goods_value_eles = action.find_ele_child(tmpele,
                                                 p.商品详情页.商品参数列表_商品参数值s,
                                                 is_Multiple=True,
                                                 wait=3)
        if len(goods_value_eles) > 0:
            productname_ele = goods_value_eles[0]
            break
    if productname_ele == None:
        raise NotFoundElementError

    action.get_img('商品详情页')
    productname = action.get_text_ele(productname_ele)

    return productname
Beispiel #16
0
def action():
    env = Environment().get_environment_info()
    capabilities = {'platformName': env.devices[0].platform_name,
                    'platformVersion': env.devices[0].platform_version,
                    'deviceName': env.devices[0].device_name,
                    'appPackage': 'in.togetu.video',
                    'clearSystemFiles': True,
                    'appActivity': env.app_activity,

                    'noReset':True,
                    'noSign': True
                    }
    host = "http://localhost:4723/wd/hub"
    driver = webdriver.Remote(host, capabilities)
    yield ElementActions(driver).reset(driver)
    driver.quit()
Beispiel #17
0
def action2():
    env = Environment().get_environment_info()
    capabilities = {
        'platformName': env.devices[0].platform_name,
        'platformVersion': env.devices[0].platform_version,
        'deviceName': env.devices[0].device_name,
        'app': env.apk,
        'clearSystemFiles': True,
        'appActivity': env.app_activity,
        'appPackage': env.app_package,
        #'automationName': 'UIAutomator2',
        'noSign': True,
        'noReset': True,
        'systemPort': random.randint(4700, 4900)
    }
    host = "http://localhost:4724/wd/hub"
    driver = webdriver.Remote(host, capabilities)
    yield ElementActions(driver).reset(driver)
    driver.quit()
Beispiel #18
0
 def pageinto(self, action: ElementActions, key="专场"):
     categorylistpage = CategoryListPage()
     categorylistpage.pageinto(action)
     action.text(categorylistpage.搜索输入框, key).click(categorylistpage.搜索按钮)
Beispiel #19
0
# -*- coding: utf-8 -*-

__author__ = 'Mio4kon'

from appium import webdriver
from base.action import ElementActions
from utils.environment import Environment

env = Environment().get_environment_info()
capabilities = {
    'platformName': env.devices[0].platform_name,
    'platformVersion': env.devices[0].platform_version,
    'deviceName': env.devices[0].device_name,
    'app': env.apk,
    'clearSystemFiles': True,
    'appActivity': env.app_activity,
    'appPackage': env.app_package,
    'automationName': 'UIAutomator2',
    'noSign': True,
    'newCommandTimeout': 60 * 100
}
host = "http://localhost:4723/wd/hub"
driver = webdriver.Remote(host, capabilities)
action = ElementActions(driver)
Beispiel #20
0
def action(driverenv):
    element_action=ElementActions(driverenv)
    yield element_action   #返回并且挂载ElementActions的实例,在对应作用域结束前,执行driver.quit()

    element_action.driver.quit()
Beispiel #21
0
    def test_login(self, action: ElementActions):
        L.d('test_login')
        """
        检查是否在登录状态,在登陆的话就退出登录再登录
        """
        action.click(HomePage.我的)
        if action.is_text_displayed('like'):
            action.click(MyPage.设置)
            action.click(SettingPage.登出)
            action.click(SettingPage.确定)
            action.click(HomePage.我的)

        else: pass
        action.click(HomePage.登陆按钮)
        action.sleep(1)
        action.text(LoginPage.手机号, '96522075359')
        action.click(LoginPage.获取验证码)
        action.sleep(1)
        action.text(LoginPage.密码, '2333')
        action.sleep(0.5)
        action.click(LoginPage.登陆)
        assert action.get_text(MyPage.名字) == 'kirua'
Beispiel #22
0
    def test_comment(self, action: ElementActions):

        action.sleep(1)
        action.click(HomePage.评论按钮)
        action.sleep(1)
        action.click(CommentPage.评论框打开)
        action.text(CommentPage.评论框输入, 'nice')
        action.click(CommentPage.评论发送)
        action.sleep(1)
        assert action.is_text_displayed('nice')
Beispiel #23
0
 def test_rrtv_login(self, action: ElementActions):
     L.d('rrtv login')
     account = Steps.get_account()
     action.click(MyPage.我的)
     action.click(MyPage.头像)
     action.click(LoginPage.账号密码登录)
     action.text(LoginPage.账户, account[0])
     action.back_press()
     action.text(LoginPage.密码, account[1])
     action.back_press()
     action.click(LoginPage.登录)
     assert action.is_text_displayed("test")
Beispiel #24
0
 def login(self, action: ElementActions, account, password):
     self.switch_密码登录tag(action)
     action.text(self.账号输入框, account).text(self.密码输入框,
                                           password).click(self.登录按钮)
     action.sleep(5)
Beispiel #25
0
 def switch_密码登录tag(self, action: ElementActions):
     action.click(self.密码登录tag)
Beispiel #26
0
    def test_otherHomepage(self, action: ElementActions):
        uper = action.get_text(HomePage.作者名称)

        action.click(HomePage.作者头像)
        assert uper == action.get_text(MyPage.名字)
Beispiel #27
0
 def pageinto(self, action: ElementActions):
     from .set import ProductPages as p
     p.特卖首页.pageinto(action)
     action.tap(p.特卖首页.进入用户中心按钮)
Beispiel #28
0
 def pageinto(self, action: ElementActions):
     usercenter = UserCenterPage()
     usercenter.pageinto(action)
     action.click(usercenter.设置按钮)
 def open_person_info(self, action: ElementActions):
     action.click(MyPage.我的)
     action.click(MyPage.已登录头像)
     action.click(UpOwnerPage.编辑)
Beispiel #30
0
 def pageinto(self, action: ElementActions):
     action.start_activity(self.activity).sleep(0.5)