Ejemplo n.º 1
0
    def test_remove_attention(self):
        """
        组织账号取消关注企业
        """
        mine = ("text","我的")
        my_attention = ("id","com.fs.wawh:id/user_my_attention_title")
        go_see_botton = ("id","com.fs.wawh:id/go_see")
        attention_status_botton = ("id","com.fs.wawh:id/attention_status") 
        attention_him_count = ("id","com.fs.wawh:id/attention_him_count")

        sleep(1)
        find_element(self.driver,mine).click()  # 我的
        find_element(self.driver,my_attention).click() # 我的关注
        find_element(self.driver,go_see_botton).click() # 点击去看看
        before_count = find_element(self.driver,attention_him_count).text # 关注他的列表数量
        find_element(self.driver,attention_status_botton).click() # 点击取消关注


        # 下拉刷新页面
        sleep(1)
        swipeDown(self.driver,500,1)
        sleep(5)
        after_count = find_element(self.driver,attention_him_count).text

        # 判断关注数-1
        differ_count = int(before_count) - int(after_count)
        assert differ_count == 1

        self.driver.close_app()
        print("取消关注成功")
        '''
Ejemplo n.º 2
0
def get_chat_msg_by_xiaobing(driver1, word):
    if driver1 == None:
        driver1 = sw.Chrome(executable_path='chromedriver.exe')
        driver1.get("https://api.weibo.com/chat/#/chat?source_from=5")

        driver1.delete_all_cookies()
		cookies = []
        for a in cookies:
            driver1.add_cookie(a)
        driver1.refresh()

        xiaobing = ('xpath', '//*[@id="app"]/div/div/div[1]/div[3]/div/div[1]/div/div/ul/li')
        find_element(driver1, xiaobing).click()

        time.sleep(1)
        msg_box = ('id', 'webchat-textarea')
        e = find_element(driver1, msg_box)
        e.send_keys(word)
        e.send_keys(Keys.ENTER)
        # time.sleep(2)
        # chat_content = ('class name', 'chat-content')
        # e = find_element(driver1, chat_content)
        time.sleep(2)
        chat_content = ('class name', 'chat-content')
        e = find_element(driver1, chat_content)
        if e.text.split('\n')[-1] == word:
            time.sleep(1)
            chat_content = ('class name', 'chat-content')
            e = find_element(driver1, chat_content)
        return driver1,e.text.split('\n')[-1]

        return driver1,e.text.split('\n')[-1]
Ejemplo n.º 3
0
def taobao_12(config_caps):
    #参数是链接手机的配置,这是淘宝自动做任务领取币脚本,请先登录淘宝账号
    driver = webdriver.Remote('http://*****:*****@content-desc="互动城"]/android.widget.FrameLayout[1]/android.widget.ImageView'),10)
    sleep(3)
    if True:
        #固定坐标点击进入
        driver.tap([(770, 1090)])
        # elem.click()
    else:
        print('元素没有找到')
    #签到领红包
    sleep(5)
    asser, elem = is_element_cunzai(driver, (
        'xpath',
        '//android.webkit.WebView[@content-desc="金币小镇双12欢乐造红包"]/android.app.Dialog/android.widget.Button[4]'
    ), 10)
    if asser:
        elem.click()
    print('已签到')
    try:
        find_element(driver, locator=('aid', '立即领取欢乐币')).click()
        find_element(driver, locator=('aid', '领欢乐币')).click()
    except:
        print('元素定位失败')
    #检查是否可点击
    asser, elem = is_element_cunzai(driver, ('aid', '去打卡'), 3)

    if asser:
        elem.click()
    print('已打卡')
    asser, elem = is_element_cunzai(driver, ('content-desc', '去完成'), 2)
    #查找是否有任务需要去完成
    while asser:
        if asser:
            elem.click()
            driver.implicitly_wait(10)
            #页面停留时间
            sleep(18)
            driver.back()

    #领取任务奖励
    asser, elem = is_element_cunzai(driver, ('aid', '立即领取'), 2)
    #存在就领取
    while asser:
        elem.click()
        print('领取红包')
    driver.back()
    #升级
    while True:
        asser, elem = is_element_cunzai(driver, ('text', '升级领红包'), 2)
        if asser:
            elem.click()
        else:
            break
    print('今日任务已完成')
    driver.close_app()
Ejemplo n.º 4
0
    def test_logout(self):
        """
        退出登录
        """
        mine = ("text", "我的")
        setting = ("text", "设置")
        logout = ("id", "com.fs.wawh:id/btn_login")
        logout_sure = ("id", "com.fs.wawh:id/btn_right")

        find_element(self.driver, mine).click()
        # 滑动页面至设置
        sleep(1)
        swipeUp(self.driver, 500, 1)
        find_element(self.driver, setting).click()
        find_element(self.driver, logout).click()
        find_element(self.driver, logout_sure).click()

        # 滑动页面至登录/注册
        sleep(2)
        swipeDown(self.driver, 500, 1)

        # 判断是否已退出登录
        login_regist_bot = ("text", "登录/注册")
        assert assert_element_exist(self.driver, login_regist_bot) == True
        sleep(3)
        #self.driver.close_app()
        print("退出登录成功")
        self.driver.quit()
Ejemplo n.º 5
0
# 安卓8.1之后:adb shell dumpsys activity | findstr "mResume"
desired_caps['appActivity'] = '.app.ui.activity.MainActivity'  # 同上↑
desired_caps['unicodeKeyboard'] = True  # 为了支持中文
desired_caps['resetKeyboard'] = True  # 设置成appium自带的键盘
# 去打开app,并且返回当前app的操作对象
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

password = ("id", "com.zhihu.android:id/password")
username = ("id", "com.zhihu.android:id/email_input_view")
go_to_btn = ("id", "com.zhihu.android:id/go_to_btn")

cacelbutn = ("aui", "取消")
userlogin = ("id", "com.zhihu.android:id/btn_progress")
questions = ("id", "com.zhihu.android:id/ask_question")

find_element(driver, go_to_btn).click()
find_element(driver, username).send_keys('17712829356')
find_element(driver, password).send_keys('scr5338287')
find_element(driver, userlogin).click()

try:
    find_element(driver, cacelbutn).click()
    print("找到取消按钮,已点击取消按钮!")
except:
    print("没有找到取消按钮!")

try:
    find_element(driver, questions)
    print("登录成功!")
except:
    print("登录失败!")
Ejemplo n.º 6
0
desired_caps = {}
desired_caps['platformName'] = 'Android'  # 打开什么平台的app,固定的 > 启动安卓平台
desired_caps[
    'platformVersion'] = '5.1.1'  # 安卓系统的版本号:adb shell getprop ro.build.version.release
desired_caps[
    'deviceName'] = 'vivo x6plus d'  # 手机/模拟器的型号:adb shell getprop ro.product.model
desired_caps['appPackage'] = 'com.allsaprk.dh.allspark'  # app的名字:
# 安卓8.1之前:adb shell dumpsys activity | findstr "mFocusedActivity"
# 安卓8.1之后:adb shell dumpsys activity | findstr "mResume"
desired_caps['appActivity'] = '.activity.LoginActivity'  # 同上↑
desired_caps['unicodeKeyboard'] = True  # 为了支持中文
desired_caps['resetKeyboard'] = True  # 设置成appium自带的键盘
# 去打开app,并且返回当前app的操作对象
driver = webdriver.Remote('http://localhost:4723/wd/hub',
                          desired_caps)  # 打开指定手机里面的软件;driver=定位软件的句柄

username = ("id", "com.allsaprk.dh.allspark:id/et_user")
password = ("id", "com.allsaprk.dh.allspark:id/et_pass")
loginbtn = ("id", "com.allsaprk.dh.allspark:id/bt_login")

find_element(driver, username).send_keys("17781780824")
find_element(driver, password).send_keys("1234")
click(driver, loginbtn)

time.sleep(3)
try:
    assert ".activity.MainActivity" == driver.current_activity
    print("登录成功!")
except:
    print("登录失败")
Ejemplo n.º 7
0
# # 2. xpath
# driver.find_element_by_xpath('//android.widget.TextView[@content-desc="Custom View"]').click()

# 3. id > resource_id
# driver.find_element_by_id('android:id/text1').click()

# 4. 文本值
# driver.find_element_by_android_uiautomator('new UiSelector().text("App")').click()

app = ("aui", "App")
search = ("aui", "Search")
invoke_search = ("aui", "Invoke Search")
datas = ("id", "io.appium.android.apis:id/txt_query_prefill")
# find_element(driver, app).click()
# assert shifoucunzai("Search") == True

app_text = find_element(driver, app).text
print(app_text)

click(driver, app)
click(driver, search)
click(driver, invoke_search)
find_element(driver, datas).send_keys("我不要当点点点!")
find_element(driver, datas).clear()

# assert is_exsit(driver, search) == True

driver.quit()

Ejemplo n.º 8
0
# driver.find_element_by_android_uiautomator('new UiSelector().text("App")').click()
# driver.quit()
driver.find_element_by_xpath(
    '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.Button[2]'
).click()
time.sleep(1)
driver.find_element_by_xpath(
    '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.Button[2]'
).click()
time.sleep(5)
#没有办法定位元素,就去点击坐标
driver.tap([(354, 1088)])
time.sleep(5)
# driver.implicitly_wait(5)
mu_btn = ('text', '我的')
find_element(driver, my_btn).click()

# driver.find_element_by_android_uiautomator('new UiSelector().text("我的")').click()
time.sleep(3)
username = '******'
driver.find_element_by_xpath(username).send_keys('yangjiasheng')
password = '******'
driver.find_element_by_xpath(password).send_keys('a12345678')
driver.find_element_by_xpath(
    '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[8]'
).click()
time.sleep(5)

assert driver.find_elements_by_accessibility_id('通知公告').text == '通知公告'
print('登陆成功 ')
Ejemplo n.º 9
0
    def test_add_address(self):
        """
        新增地址
        """
        mine = ("text", "我的")
        address_manage = ("text", "地址管理")
        add_address = ("id", "com.fs.wawh:id/my_address_add_button")
        address_name = ("id", "com.fs.wawh:id/add_address_name_edit")
        address_phone = ("id", "com.fs.wawh:id/add_address_phone_edit")
        address_postal_code = ("id",
                               "com.fs.wawh:id/add_address_postal_code_text")
        address_area = ("id", "com.fs.wawh:id/add_address_address_show_text")
        area_sure = ("id", "com.fs.wawh:id/btn_sure")
        address_detailed = ("id",
                            "com.fs.wawh:id/add_address_detailed_address_edit")
        address_save = ("id", "com.fs.wawh:id/add_address_save_button")

        find_element(self.driver, mine).click()  # 我的
        # 滑动页面至地址管理
        sleep(1)
        swipeUp(self.driver, 500, 1)
        find_element(self.driver, address_manage).click()  # 地址管理
        find_element(self.driver, add_address).click()  # 新增收货地址

        add_address_name = 'huang'
        find_element(self.driver,
                     address_name).send_keys(add_address_name)  # 姓名
        find_element(self.driver,
                     address_phone).send_keys('13700001010')  # 联系电话
        find_element(self.driver,
                     address_postal_code).send_keys('518000')  # 邮政编码
        find_element(self.driver, address_area).click()  # 所在区域
        find_element(self.driver, area_sure).click()  # 确认区域
        find_element(self.driver, address_detailed).send_keys(
            '天安数码城天吉大厦CD座4楼4D1、4D2室')  # 详细地址
        find_element(self.driver, address_save).click()  # 保存

        # 判断是否新增成功
        list_address_name = ("text", add_address_name)
        assert assert_element_exist(self.driver, list_address_name) == True

        self.driver.close_app()

        print("新增地址成功")
Ejemplo n.º 10
0
        # time.sleep(2)
        # chat_content = ('class name', 'chat-content')
        # e = find_element(driver1, chat_content)
        time.sleep(2)
        chat_content = ('class name', 'chat-content')
        e = find_element(driver1, chat_content)
        if e.text.split('\n')[-1] == word:
            time.sleep(1)
            chat_content = ('class name', 'chat-content')
            e = find_element(driver1, chat_content)
        return driver1,e.text.split('\n')[-1]

        return driver1,e.text.split('\n')[-1]
    else:
        xiaobing = ('xpath', '//*[@id="app"]/div/div/div[1]/div[3]/div/div[1]/div/div/ul/li')
        find_element(driver1, xiaobing).click()

        time.sleep(1)
        msg_box = ('id', 'webchat-textarea')
        e = find_element(driver1, msg_box)
        e.send_keys(word)
        e.send_keys(Keys.ENTER)
        time.sleep(2)
        chat_content = ('class name', 'chat-content')
        e = find_element(driver1, chat_content)
        if e.text.split('\n')[-1] == word:
            time.sleep(1)
            chat_content = ('class name', 'chat-content')
            e = find_element(driver1, chat_content)
        return driver1,e.text.split('\n')[-1]
Ejemplo n.º 11
0
    def test_join_action(self):
        """
        企业账号报名活动
        """
        index = ("text", "首页")
        my_org = ("id", "com.fs.wawh:id/logo")
        action = ("id", "com.fs.wawh:id/action_item_logo")
        apply = ("id", "com.fs.wawh:id/tv_release")
        name = ("id", "com.fs.wawh:id/et_name")
        phone = ("id", "com.fs.wawh:id/et_phone")
        apply_join = ("id", "com.fs.wawh:id/tv_join")

        find_element(self.driver, index).click()
        find_element(self.driver, my_org).click()
        find_element(self.driver, action).click()
        find_element(self.driver, apply).click()
        find_element(self.driver, name).send_keys("林生")
        find_element(self.driver, phone).send_keys("13427906733")
        find_element(self.driver, apply_join).click()

        # 判断是否成功报名活动
        succeed = ("text", "已报名活动")
        assert assert_element_exist(self.driver, succeed) == True
        sleep(3)
        self.driver.close_app()
        print("已报名活动")
Ejemplo n.º 12
0
    def test_01_login_org(self):
        """
        组织账户登录
        """
        mine = ("text", "我的")
        login_regist_bot = ("text", "登录/注册")
        login_tpye_password = ("id", "com.fs.wawh:id/tv_login_type")
        username = ("id", "com.fs.wawh:id/user_login_id")
        password = ("id", "com.fs.wawh:id/user_login_password")
        login_bot = ("id", "com.fs.wawh:id/btn_login")
        search_key = ("text", "惠州市社会组织总会")
        sleep(3)
        find_element(self.driver, mine).click()
        find_element(self.driver, login_regist_bot).click()
        find_element(self.driver, login_tpye_password).click()
        find_element(self.driver, username).clear()
        find_element(self.driver, username).send_keys("13700001010")
        find_element(self.driver, password).send_keys("qwe123456")
        find_element(self.driver, login_bot).click()

        assert assert_element_exist(self.driver, search_key) == True
        sleep(3)
        self.driver.close_app()
        print("登录成功")
Ejemplo n.º 13
0
    def test_add_news(self):
        """
        组织账号发布资讯
        """
        # 获取设备分辨率,此设备为 1080*1920
        size = self.driver.get_window_size()
        x = (size['width'])
        y = (size['height'])
        # 获取实时发布时间作为标题
        time = datetime.datetime.now().strftime
        news_dt = time('%Y-%m-%d %H:%M:%S')
        news_title_text = "发布资讯测试" + news_dt

        mine = ("text", "我的")
        home_page_bot = ("id", "com.fs.wawh:id/btn_home_page")
        fab_up = ("id", "com.fs.wawh:id/fab_up")
        release_news_bot = ("id", "com.fs.wawh:id/btn_release_actions")
        news_title = ("id", "com.fs.wawh:id/et_register_content")

        find_element(self.driver, mine).click()
        find_element(self.driver, home_page_bot).click()
        find_element(self.driver, fab_up).click()
        find_element(self.driver, release_news_bot).click()
        find_element(self.driver, news_title).send_keys(news_title_text)

        # 资讯类型  700 447 1030 510
        sleep(1)
        self.driver.tap([(x * 0.65, y * 0.24), (x * 0.95, y * 0.26)], 100)
        sleep(1)
        # 955 1230  1020 1260
        self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100)
        sleep(1)

        # 分类 700 597  1030 660
        self.driver.tap([(x * 0.65, y * 0.32), (x * 0.95, y * 0.34)], 100)
        sleep(1)
        self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100)

        # 资讯图片
        add_photo = ("id", "com.fs.wawh:id/add_photo")
        image = ("id", "com.fs.wawh:id/image_view_album_image")
        image_select = ("id", "com.fs.wawh:id/image_view_image_select")
        add_image = ("id", "com.fs.wawh:id/menu_item_add_image")
        find_element(self.driver, add_photo).click()
        find_element(self.driver, image).click()
        find_element(self.driver, image_select).click()
        find_element(self.driver, add_image).click()

        # 资讯介绍
        news_content = ("id", "com.fs.wawh:id/et_info")
        find_element(self.driver, news_content).send_keys(
            "利用生活实践经验引入教学生活处处有数学。教学时,在观察中讲理旦罚测核爻姑诧太超咖论,从实践中引入概念,增加学生对概念的理解和兴趣。"
        )

        # 发布资讯
        release_news = ("id", "com.fs.wawh:id/tv_commit")
        find_element(self.driver, release_news).click()

        # 判断是否发布成功
        succeed = ("text", "提交成功")
        assert assert_element_exist(self.driver, succeed) == True

        self.driver.close_app()
        print("发布资讯成功")
Ejemplo n.º 14
0
    def test_02_add_ation(self):
        """
        组织账号发布活动
        """
        # 获取设备分辨率,此设备为 1080*1920
        size = self.driver.get_window_size()
        x = (size['width'])
        y = (size['height'])
        # 获取实时发布时间作为标题
        time = datetime.datetime.now().strftime
        action_dt = time('%Y-%m-%d %H:%M:%S')
        ation_title_text = "发布活动测试" + action_dt

        mine = ("text", "我的")
        home_page_bot = ("id", "com.fs.wawh:id/btn_home_page")
        fab_up = ("id", "com.fs.wawh:id/fab_up")
        release_ations_bot = ("id", "com.fs.wawh:id/btn_release_news")
        ation_title = ("id", "com.fs.wawh:id/et_register_content")

        find_element(self.driver, mine).click()
        find_element(self.driver, home_page_bot).click()
        find_element(self.driver, fab_up).click()
        find_element(self.driver, release_ations_bot).click()
        find_element(self.driver, ation_title).send_keys(ation_title_text)

        join_time = ("id", "com.fs.wawh:id/tv_join_time")
        time_int = int(time('%d'))
        time_str = str(time_int)
        join_start_time = ("text", time_str)
        start_time_ok = ("id", "com.fs.wawh:id/tv_ok")
        ation_time = ("id", "com.fs.wawh:id/tv_activity_time")
        ation_start_time = ("text", time_str)

        # 报名时间
        find_element(self.driver, join_time).click()
        find_element(self.driver, join_start_time).click()
        sleep(1)
        self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100)
        sleep(1)
        swipeUp(self.driver, 1000, 1)
        sleep(1)
        find_element(self.driver, join_start_time).click()
        sleep(1)
        self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100)
        sleep(1)
        find_element(self.driver, start_time_ok).click()

        # 活动时间
        find_element(self.driver, ation_time).click()
        find_element(self.driver, ation_start_time).click()
        sleep(1)
        self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100)
        sleep(1)
        swipeUp(self.driver, 1000, 1)
        sleep(1)
        find_element(self.driver, ation_start_time).click()
        sleep(1)
        self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100)
        sleep(1)
        find_element(self.driver, start_time_ok).click()

        action_locate_sure = ("id", "com.fs.wawh:id/btn_sure")
        action_locate_detail = ("id", "com.fs.wawh:id/et_locate_detail")
        host_unit = ("text", "请输入举办单位")
        action_cost = ("text", "请输入活动费用")
        action_num = ("text", "请输入报名人数")
        join_limit_num = ("text", "请输入报名限制人数")

        # 活动地点
        sleep(1)
        self.driver.tap([(x * 0.65, y * 0.46), (x * 0.95, y * 0.47)], 100)
        find_element(self.driver, action_locate_sure).click()

        # 详细地址
        find_element(self.driver,
                     action_locate_detail).send_keys("香密湖街道办天安数码城天吉大厦")

        # 举办单位
        find_element(self.driver, host_unit).send_keys("深圳市壹办公科技股份有限公司")

        # 活动费用
        find_element(self.driver, action_cost).send_keys("80")
        # 活动人数
        find_element(self.driver, action_num).send_keys("50")

        # 滑动页面
        sleep(1)
        swipeUp(self.driver, 500, 1)

        # 报名限制人数
        find_element(self.driver, join_limit_num).send_keys("3")

        # 活动图片
        add_photo = ("id", "com.fs.wawh:id/add_photo")
        image = ("id", "com.fs.wawh:id/image_view_album_image")
        image_select = ("id", "com.fs.wawh:id/image_view_image_select")
        add_image = ("id", "com.fs.wawh:id/menu_item_add_image")
        find_element(self.driver, add_photo).click()
        find_element(self.driver, image).click()
        find_element(self.driver, image_select).click()
        find_element(self.driver, add_image).click()

        # 活动介绍
        action_content = ("id", "com.fs.wawh:id/et_activity_content")
        find_element(self.driver, action_content).send_keys(
            "利用生活实践经验引入教学生活处处有数学。教学时,在观察中讲理旦罚测核爻姑诧太超咖论,从实践中引入概念,增加学生对概念的理解和兴趣。"
        )

        # 发布活动
        release_action = ("id", "com.fs.wawh:id/tv_commit")
        find_element(self.driver, release_action).click()

        # 判断是否发布成功
        succeed = ("text", "提交成功")
        assert assert_element_exist(self.driver, succeed) == True

        self.driver.close_app()
        print("发布活动成功")
Ejemplo n.º 15
0
Archivo: putong.py Proyecto: csw279/new
import time
from appiumtools import find_element, get_driver

driver = get_driver('Android', '5.1.1', 'xiaomi 8', 'io.appium.android.apis',
                    '.ApiDemos')

####  定位元素首选 by_aui(文本值),by_xpath,by_aid(accessbility_id)  这三种
####   by_id 是根据resource_id来的
a = ('aid', 'Accessibility')
b = (
    'xpath',
    '/hierarchy/android.widget.FrameLayout/android.view.View/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.view.View[1]'
)
c = ('aui', 'Custom View')
find_element(driver, a).click()
find_element(driver, c).click()
find_element(driver, b).click()
# find_element(driver,b).send_keys('aaa')
try:
    assert driver.current_activity == '.accessibility.CustomViewAccessibilityActivity'
    print('测试成功')
except:
    print('测试失败')