Running mobile network test on Android using simulator
I'll assume you've downloaded it Python SDK , the agent and developer token have been configured and the agent is running. If not, you can read how to do it in this article. In addition, I'll assume you've created and started Simulator running Android.
Let's take this test as an example:
import pytest from appium import webdriver from tests.pageobjects.web import LoginPage, ProfilePage @pytest.fixture def driver(): desired_capabilities = { "udid": "emulator-5554", "browserName": "chrome", "platformName": "Android", } driver = webdriver.Remote(desired_capabilities=desired_capabilities) yield driver driver.quit() def test_example_on_chrome_on_android(driver): LoginPage(driver).open().login_as("John Smith", "12345") profile_page = ProfilePage(driver) profile_page.update_profile( "United States", "Street name and number", "john.smith@somewhere.tld", "+1 555 555 55", ) assert profile_page.saved_message_is_displayed() is True
As you defined, desired_capabilities, you can run this test on a simulator named that runs Android. Specifying the browser name (i.e. browser name) means that we are running a mobile Web test. emulator-5554chrome
To turn the Appium test into a TestProject based test, similar to the Selenium based test, you need to change the import statement:
from appium import webdriver # reach from src.testproject.sdk.drivers import webdriver
Also: you no longer need to run your Appium server because TestProject Agent Can act as Appium server for you!
When you run this test, it will start on your Android emulator Chrome browser And run the test:
After the test is completed and executed, the SDK will send the report to the agent, and the agent will create a new test report on the TestProject platform in turn:
Running native application tests on iOS using real devices
As you read earlier, the TestProject Python SDK supports both Android and iOS. Let's look at an example test that tests a native iOS application running on a real iPhone:
import pytest from src.testproject.sdk.drivers import webdriver from tests.pageobjects.android import LoginPage, ProfilePage @pytest.fixture def driver(): desired_capabilities = { "udid": "<my_device_udid_here>", "deviceName": "iPhone van Bas", "browserName": "", "platformName": "iOS", "bundleId": "io.testproject.Demo", } driver = webdriver.Remote(desired_capabilities=desired_capabilities) yield driver driver.close_app() driver.quit() def test_example_on_native_ios_app(driver): LoginPage(driver).login_as("John Smith", "12345") profile_page = ProfilePage(driver) profile_page.update_profile( "United States", "Street name and number", "john.smith@somewhere.tld", "+1 555 555 55", ) assert profile_page.saved_message_is_displayed() is True
No browser desired specified_ Capabilities, which means that this test is run against native applications. The following is a screenshot of the actual iOS device used during the test execution:
Fact interesting fact: the iOS device used here is connected to a Windows computer! With TestProject, you can run tests on iOS devices without running macOS or XCode or running Appium server yourself.
As we can see in the report sent to TestProject, the test also passed:
As you can see, using the TestProject Python SDK (or Java or C SDK), you can easily convert existing Appium based tests to TestProject driven tests. Whether they are used for Android or iOS, you can use emulators or real devices to test mobile Web or native applications on macOS, Linux and Windows.