跳至內容

Change device orientation Landscape and Portrait in Appium Robot Framework

0

Im using Appium Robot framework and wanted to know how i can change the device orientation for iOS and Android devices in device farm, Is there any support provided by device farm to test it. I saw that when accessing the device farm devcie remotely there's an option , but when running the automation tests by creating new run and submitting all the artifacts "APPIUM PYTHON", there's no configuration present to change the device orientation

已提問 3 個月前檢視次數 25 次
1 個回答
0

When running Appium tests in AWS Device Farm, you can change device orientation programmatically within your Appium Robot Framework tests rather than through Device Farm configuration.

For both iOS and Android devices, you can use Appium's capabilities to control device orientation by adding commands in your test script. Here's how you can implement this in your Robot Framework tests:

*** Keywords ***
Set Device Orientation To Landscape
Execute Driver Script    driver.orientation = "LANDSCAPE"

Set Device Orientation To Portrait
Execute Driver Script    driver.orientation = "PORTRAIT"

You can also fine-tune your Appium server parameters in Device Farm by adjusting the default Appium capabilities in your test spec file. For example, you could include orientation-related capabilities in your pre_test phase:

phases:
pre_test:
- # Start up Appium with custom capabilities
- >-
appium --log-timestamp
--default-capabilities "{\"deviceName\": \"$DEVICEFARM_DEVICE_NAME\", 
\"platformName\":\"$DEVICEFARM_DEVICE_PLATFORM_NAME\", 
\"app\":\"$DEVICEFARM_APP_PATH\",
\"automationName\":\"XCUITest\", 
\"udid\":\"$DEVICEFARM_DEVICE_UDID_FOR_APPIUM\", 
\"platformVersion\":\"$DEVICEFARM_DEVICE_OS_VERSION\"}"
>> $DEVICEFARM_LOG_DIR/appiumlog.txt 2>&1 &

Remember that while the remote access interface provides UI controls for changing orientation, for automated tests you need to implement the orientation changes directly in your test code using Appium commands.
Sources
Speeding up Appium-based tests in Device Farm through desired capabilities - AWS Device Farm
Extending custom test environments in Device Farm - AWS Device Farm

已回答 3 個月前
  • Getting error 'No keyword with name 'Execute Driver Script' found.', is the above solution correct

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。