Esempio n. 1
0
def test_element_scroll_visible(c: wda.Client):
    with c.session('com.apple.Preferences') as s:
        general = s(name='General')
        assert not general.get().visible
        general.scroll()
        assert general.get().visible
        time.sleep(1)
Esempio n. 2
0
def test_element_tap_hold(c: wda.Client):
    s = c.session()
    s(name='Settings').tap_hold(2.0)
    assert s(
        classChain=
        '**/Icon[`name == "Weather"`]/Button[`name == "DeleteButton"`]').get(
            2.0, raise_error=False)
Esempio n. 3
0
def test_client_session_with_argument(client: wda.Client):
    """
    In mose case, used to open browser with url
    """
    with client.session('com.apple.mobilesafari', ['-u', 'https://www.github.com']) as s:
        # time.sleep(1.0)
        # s(id='URL').wait()
        assert s(name='Share', className="Button").wait()
Esempio n. 4
0
def test_session_orientation(c: wda.Client):
    with c.session('com.apple.mobilesafari') as s:
        assert s.orientation == wda.PORTRAIT
        s.orientation = wda.LANDSCAPE
        time.sleep(1.0)
        assert s.orientation == wda.LANDSCAPE
        # recover orientation
        s.orientation = wda.PORTRAIT
Esempio n. 5
0
def test_element_pinch(c: wda.Client):
    with c.session('com.apple.Maps') as s:

        def alert_callback(s):
            s.alert.accept()

        s.set_alert_callback(alert_callback)
        s(className='Button', name='Tracking').tap()
        time.sleep(5)
Esempio n. 6
0
def test_text_contains_matches(c: wda.Client):
    with c.session('com.apple.Preferences') as s:
        s(text='Bluetooth').get()
        assert s(textContains="Blue").exists
        assert not s(text="Blue").exists
        assert s(text="Bluetooth").exists
        assert s(textMatches="Blue?").exists
        assert s(nameMatches="Blue?").exists
        assert not s(textMatches="^lue?").exists
        assert not s(textMatches="^Blue$").exists
        assert s(textMatches=r"^(Blue|Red).*").exists
Esempio n. 7
0
def test_element_properties(c: wda.Client):
    with c.session('com.apple.mobilesafari',
                   ['-u', 'https://www.github.com']) as s:
        time.sleep(1.0)
        u = None
        for e in s(id='URL').find_elements():
            if e.className.endswith('Button'):
                u = e
                break
        assert u.label == 'Address'
        assert 'github' in u.value.lower()
        assert u.displayed == True
        assert u.visible == True
        assert u.enabled == True
        assert type(u.bounds) is wda.Rect
        u.clear_text()
        u.set_text('status.github.com\n')
        assert 'status' in u.value
def test_preferences(c: wda.Client):
    print("Status:", c.status())
    print("Info:", c.info)
    print("BatteryInfo", c.battery_info())
    print("AppCurrent:", c.app_current())
    # page_source = c.source()
    # assert "</XCUIElementTypeApplication>" in page_source

    app = c.session(bundle_id)
    selector = app(label="蜂窝网络")
    el = selector.get() 
    el.click()
    print("Element bounds:", el.bounds)

    logger.info("Take screenshot: %s", app.screenshot())
    
    app.swipe_right()
    app.swipe_up()

    app(label="电池").scroll()
    app(label="电池").click()
Esempio n. 9
0
def test_app_operation(c: wda.Client):
    c.session("com.apple.Preferences")
    appinfo = c.app_current()
    assert appinfo['bundleId'] == 'com.apple.Preferences'
def test_invalid_session(c: wda.Client):
    app = c.session("com.apple.Preferences")
    # kill app here
    app.session_id = "no-exists"
    app(label="Haha").exists
def test_open_safari(c: wda.Client):
    """ session操作 """
    app = c.session("com.apple.mobilesafari")
    app.deactivate(3) # 后台3s
    app.close() # 关闭
Esempio n. 12
0
def test_main(c: wda.Client):
    t = tidevice.Device()
    with make_screenrecord(c, t, "output.mp4"):
        app = c.session("com.apple.Preferences")
        app(label="蓝牙").click()
        c.sleep(1)
Esempio n. 13
0
def test_client_session_without_argument(client: wda.Client):
    s = client.session('com.apple.Health')
    session_id = client.status()['sessionId']
    assert s.id == session_id
    assert s.bundle_id == 'com.apple.Health'
    s.close()
Esempio n. 14
0
def test_session_invalid_with_autofix(c: wda.Client):
    c.session("com.apple.Preferences")
    c.session_id = "123"
    assert c.app_current().bundleId == "com.apple.Preferences"
    assert isinstance(c.info, dict)
    assert c.session_id != "123"
Esempio n. 15
0
def test_element_scroll_direction(c: wda.Client):
    with c.session('com.apple.Preferences') as s:
        s(className='Table').scroll('up', 0.1)
Esempio n. 16
0
def test_element_name_matches(c: wda.Client):
    s = c.session("com.apple.Preferences")
    assert s(nameMatches='^蓝牙').exists
    info = s(nameMatches='^蓝牙').info
    assert info['label'] == '蓝牙'