def driver():

    app_activity = os.environ.get("TP_ANDROID_AUT_ACTIVITY", None)
    app_package = os.environ.get("TP_ANDROID_AUT_PACKAGE", None)
    emulator_id = os.environ.get("TP_ANDROID_DUT_UDID", None)

    if not all([app_activity, app_package, emulator_id]):
        raise KeyError("Not all environment variables were set correctly.")

    desired_capabilities = {
        "appActivity": app_activity,
        "appPackage": app_package,
        "udid": emulator_id,
        "browserName": "",
        "platformName": "Android",
        "unicodeKeyboard": "true",
        "resetKeyboard": "true",
    }

    driver = webdriver.Remote(desired_capabilities=desired_capabilities)
    driver.start_activity(app_package=app_package, app_activity=app_activity)

    yield driver

    driver.close_app()
    driver.quit()
def start(mobileid):
    # baf8c2f7
    desired_capabilities = {
        "appActivity": "com.lock.till.MainActivity",
        "appPackage": "com.lock.till",
        "udid": mobileid,
        "browserName": "",
        "platformName": "Android"
    }
    driver = webdriver.Remote(
        token='MPENCENWGnNwy7E3OhgOucsCYRoiQXAO37dtNXA3StQ1',
        desired_capabilities=desired_capabilities)
    return driver
def test_wrong_udid():
    with pytest.raises(expected_exception=SdkException, match="Requested device was not found"):
        desired_capabilities = {
            "appActivity": "host.exp.exponent.MainActivity",
            "appPackage": "com.example.tp",
            "udid": "11",
            "platformName": "Android",
            "unicodeKeyboard": "true",
            "resetKeyboard": "true"
        }

        driver = webdriver.Remote(desired_capabilities=desired_capabilities)
        driver.quit()
Beispiel #4
0
def test_firstem():
    desired_capabilities = {
        "appActivity": "io.testproject.demo.MainActivity",
        "appPackage": "io.testproject.demo",
        "udid": "emulator-5554",
        "browserName": "",
        "platformName": "Android",
    }

    driver = webdriver.Remote(desired_capabilities=desired_capabilities)
    driver.find_element_by_id('name').send_keys('John Smith')
    driver.find_element_by_id('password').send_keys('12345')
    driver.find_element_by_id('login').click()
    driver.close_app()
    driver.quit()
Beispiel #5
0
def driver():

    emulator_id = os.environ.get("TP_ANDROID_DUT_UDID", None)

    if emulator_id is None:
        raise KeyError("TP_ANDROID_DUT_UDID variable was not set")

    desired_capabilities = {
        "udid": emulator_id,
        "browserName": "chrome",
        "platformName": "Android",
    }

    driver = webdriver.Remote(desired_capabilities=desired_capabilities)
    yield driver
    driver.quit()
def driver():

    device_id = os.environ.get("TP_IOS_DUT_UDID", None)
    device_name = os.environ.get("TP_IOS_DUT_NAME", None)

    if not all([device_id, device_name]):
        raise KeyError("Not all environment variables were set correctly.")

    desired_capabilities = {
        "udid": device_id,
        "deviceName": device_name,
        "browserName": "safari",
        "platformName": "iOS",
    }

    driver = webdriver.Remote(desired_capabilities=desired_capabilities)
    yield driver
    driver.quit()
def test_hybrid_android_app():
    desired_capabilities = {
        "appActivity": "com.lock.till.MainActivity",
        "appPackage": "com.lock.till",
        "udid": "baf8c2f7",
        "browserName": "",
        "platformName": "Android"
    }
    try:
        exception = "none"
        total = 0
        fail = 0
        email = "*****@*****.**"
        password = "******"
        tempict = {}
        driver = webdriver.Remote(
            token='MPENCENWGnNwy7E3OhgOucsCYRoiQXAO37dtNXA3StQ1',
            desired_capabilities=desired_capabilities)
        driver.reset()
        total = total + 1
        driver.implicitly_wait(40)
        for i in range(1, 3):
            time.sleep(30)
            driver.swipe(991, 1511, 99, 1517, 4559)
        coordinates = (500, 1523)
        driver.tap(coordinates)
        # driver.tap((500, 1523))
        # tempict[variable_names.pageurl]=desired_capabilities["appPackage"]
        tempict[variable_names.formname] = desired_capabilities["appPackage"]
        tempict["Email"] = email
        tempict["Password"] = password
        tempict[variable_names.expectedresult] = variable_names.passed
        print("I am here")
        # time.sleep(40)
        driver.find_element_by_xpath(
            '//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[3]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[2]/android.widget.EditText[1]'
        ).send_keys(email)
        driver.find_element_by_xpath(
            '//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[4]/android.view.View[2]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[2]/android.widget.EditText[1]'
        ).send_keys(password)
        driver.find_element_by_xpath(
            '//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[5]/android.widget.Button[1]'
        ).click()
        driver = locktill_enter_pin.enter_pin(driver, "123456")

        try:
            homescreen_element = driver.find_element_by_xpath(
                '//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[2]/android.view.View[1]/android.view.View[5]'
            )
            if homescreen_element:
                result = variable_names.passed
                tempict[variable_names.actualresult] = result
                # return result
        except Exception as e:
            exception = "none"
            result = variable_names.failed
            tempict[variable_names.actualresult] = result
            fail = fail + 1

            # return result

    except Exception as e:
        print(str(e))
    tempict[variable_names.n_exception] = exception
    tempict[variable_names.totalcount] = str(total)
    tempict[variable_names.totalfailed] = str(fail)
    jsonlist.append(tempict)
    mainlist = {}
    page_url = "https://dev.kardkey.com/#/"
    mainlist[variable_names.sample_values] = jsonlist
    mainlist[variable_names.currenttime] = variable_names.get_time()
    mainlist[variable_names.pageurl] = desired_capabilities["appPackage"]
    mainlist[variable_names.innerdata] = ""
    mainlist[variable_names.totalcount] = str(total)
    mainlist[variable_names.totalfailed] = str(fail)
    mainlist[variable_names.actualresult] = ""
    mainlist[variable_names.expectedresult] = ""
    print(mainlist)

    project_list = variable_names.show_project_name()
    id = project_list[0]
    project_name = project_list[1]
    print("I am using this info: ", id, project_name)
    pdb.set_trace()
    post_data.post_data_on_portal(
        mainlist, "Login",
        "To check weather user is able to login with a valid email and password",
        project_name, id)