예제 #1
0
def driver_setup(driver: WebDriver) -> None:
    logging.debug(f"starting driver session")

    driver.terminate_app(driver.desired_capabilities["bundleId"])
    driver.execute_script(
        "mobile: launchApp", {
            "bundleId": driver.desired_capabilities["bundleId"],
            "arguments":
            driver.desired_capabilities["processArguments"]["args"]
        })
    driver.execute_script(
        "mobile: activateApp",
        {"bundleId": driver.desired_capabilities["bundleId"]})
예제 #2
0
def test_setting():
    capabilities = {
        "deviceName": "iPhone SE",
        "udid": "b3346f9b0c4797e7a68fffb4532e1727bc23ad76",
        "platformName": "iOS",
        "automationName": "XCUITest",
        "app": "Settings",
        "xcodeSigningId": "iPhone Developer",
        "updatedWDABundleId": "com.afkTestTeam.WebDriverAgentLib",
        "shouldWaitForQuiescence": "False",
        "fastReset": True
    }

    driver = WebDriver("http://0.0.0.0:4723/wd/hub",
                       desired_capabilities=capabilities)
    driver.implicitly_wait(5)
    general = driver.find_element_by_xpath(
        '//XCUIElementTypeCell[@name="General"]')

    click_on_element(driver, general)
    accessibility = driver.find_element_by_xpath(
        '//XCUIElementTypeCell[@name="Accessibility"]')
    click_on_element(driver, accessibility)

    time.sleep(5)
    hearing_devoces = driver.find_element_by_xpath(
        '//XCUIElementTypeCell[contains(@name, "Hearing Devices")]')
    while not hearing_devoces.is_displayed():
        driver.execute_script("mobile: swipe", {"direction": "up"})

    while hearing_devoces.is_displayed():
        hearing_devoces = driver.find_element_by_xpath(
            '//XCUIElementTypeCell[contains(@name, "Hearing Devices")]')
        hearing_devoces.click()

    bluetooth_switch = driver.find_elements_by_xpath(
        '//XCUIElementTypeSwitch[@name="Bluetooth"]')

    if bluetooth_switch:
        bluetooth_switch[0].click()

    test_hearing_device(driver)

    driver.back()
    time.sleep(1)

    driver.execute_script("mobile: swipe", {"direction": "up"})

    slider = driver.find_element_by_xpath(
        '//XCUIElementTypeCell[@name="Left-Right Stereo Balance"]/XCUIElementTypeOther[3]'
    )

    old_value = slider.get_attribute('value')

    action = TouchAction(driver)
    action.tap(slider, x=randint(0, 50), y=10)
    action.perform()

    new_value = slider.get_attribute('value')
    assert old_value != new_value

    time.sleep(2)
    driver.quit()
예제 #3
0
def test_application():
    capabilities = {
        "deviceName": "iPhone SE",
        "udid": "b3346f9b0c4797e7a68fffb4532e1727bc23ad76",
        "platformName": "iOS",
        "automationName": "XCUITest",
        "app": "/Users/pavlo.tsyupka/Downloads/Nucleus Smart 1.431.2.zip",
        "xcodeSigningId": "iPhone Developer",
        "updatedWDABundleId": "com.afkTestTeam.WebDriverAgentLib",
        "shouldWaitForQuiescence": "False",
        "fastReset": True
    }

    driver = WebDriver("http://0.0.0.0:4723/wd/hub",
                       desired_capabilities=capabilities)
    driver.implicitly_wait(5)

    for _ in range(5):
        driver.execute_script("mobile: swipe", {"direction": "left"})
        time.sleep(0.125)

    demo_mode_button = driver.find_element_by_name('demoModeButton')
    demo_mode_button.click()

    volume_open_button = driver.find_element_by_xpath(
        '//XCUIElementTypeCell[@name="volume"]')
    volume_open_button.click()

    plus_button = driver.find_element_by_xpath(
        '//XCUIElementTypeOther[4]/XCUIElementTypeOther/XCUIElementTypeButton[1]'
    )
    minus_button = driver.find_element_by_xpath(
        '//XCUIElementTypeOther[4]/XCUIElementTypeOther/XCUIElementTypeButton[2]'
    )

    value_element = driver.find_element_by_xpath(
        '//XCUIElementTypeCell[@name="volume"]')
    old_value = value_element.get_attribute('value')

    plus_button.click()
    time.sleep(1)
    new_value = value_element.get_attribute('value')
    assert old_value != new_value

    minus_button.click()
    time.sleep(1)
    new_value = value_element.get_attribute('value')
    assert old_value == new_value

    menu_button = driver.find_element_by_xpath(
        '//XCUIElementTypeButton[@name="Settings menu"]')
    menu_button.click()
    time.sleep(1)

    exit_button = driver.find_element_by_xpath(
        '//XCUIElementTypeCell[@name="exitPracticeMode"]')
    exit_button.click()
    time.sleep(1)

    for _ in range(5):
        driver.execute_script("mobile: swipe", {"direction": "right"})
        time.sleep(0.125)

    driver.quit()