Skip to content

Commit 2dd3847

Browse files
sakshamarora-archIshavyas9
authored andcommitted
Updated documentation
1 parent 7184c86 commit 2dd3847

File tree

2 files changed

+135
-162
lines changed

2 files changed

+135
-162
lines changed

docs/appium-rokutv.md

Lines changed: 85 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ import TabItem from '@theme/TabItem';
5050

5151
## Tutorial To Run Your First Test On LambdaTest
5252

53-
---
5453

5554
In this topic, you will learn how to configure and run your **Roku TV** automation testing scripts with **Roku WebDriver** on **LambdaTest Real Device Cloud platform**.
5655

56+
---
57+
5758
## Objective
5859

59-
---
60+
6061

6162
By the end of this topic, you will be able to:
6263

@@ -70,19 +71,18 @@ All the code samples in this documentation can be found on **LambdaTest's Github
7071

7172
:::
7273

73-
## Prerequisites
74-
7574
---
75+
## Prerequisites
7676

7777
Before you can start performing App automation testing with Appium, you would need to follow these steps:
7878

7979
- You have access to LambdaTest username and accessKey. If you have not registered yet, you can do the same by visiting our [website](https://accounts.lambdatest.com/register). You will be able to access the credentials in the [LambdaTest Profile](https://accounts.lambdatest.com/detail/profile)
8080
- Install the latest Python build from the [official website](https://www.python.org/downloads/). We recommend using the latest version.
8181
- Make sure **pip** is installed in your system. You can install **pip** from [pip documentation](https://pip.pypa.io/en/stable/installation/).
8282

83+
---
8384
## Run your first test
8485

85-
---
8686

8787
### 1. Upload your application
8888
Upload your **Roku TV** application (.zip file) to the LambdaTest servers using our **REST API**. You need to provide your **Username** and **AccessKey** in the format `Username:AccessKey` in the **cURL** command for authentication. Make sure to add the path of the **appFile** in the cURL request. Here is an example cURL request to upload your app using our REST API:
@@ -161,64 +161,75 @@ An automation script for the sample application available above has been provide
161161
Before running the script, please make sure that the file webDriver.py from Step 2, is in the same directory as this file.
162162

163163
```python title="main.py"
164-
from webDriver import WebDriver
164+
from appium import webdriver
165+
import os
165166
import time
167+
from appium.options.android import UiAutomator2Options
166168

167-
def run(hub_url: str, caps: dict):
168-
try:
169-
web_driver = WebDriver(hub_url, caps)
170-
171-
172-
web_driver.apps()
173-
time.sleep(5)
174-
web_driver.launch_the_channel("dev")
175-
176-
for i in range(5):
177-
t = time.time()
178-
web_driver.press_btn("select")
179-
t2 = time.time()
180-
print("select time :",t2-t)
181-
time.sleep(2)
182169

170+
def getCaps():
171+
desired_caps = {
172+
"automationName": "Roku",
173+
"deviceName": "Roku Ultra",
174+
"platformVersion": "11",
175+
"platformName": "roku",
176+
"isRealMobile": True,
177+
"build": "Roku Testing",
178+
"app": "APP_URL", # Enter app url here
179+
"network": False,
180+
"devicelog": True,
181+
"privateCloud": True,
182+
"visual": True,
183+
"idleTimeout": 1800,
184+
}
185+
return desired_caps
183186

184-
web_driver.quiet()
185-
print("Test passed")
186-
except Exception as e:
187-
print(f"Error: {e}")
188-
print("Test failed")
189-
190-
if __name__ == "__main__":
191187

188+
def runTest():
192189
if os.environ.get("LT_USERNAME") is None:
193-
# Enter LT username here if environment variables have not been added
194-
username = "username"
190+
# Enter LT username below if environment variables have not been added
191+
username = "<YOUR_LT_USERNAME>"
195192
else:
196193
username = os.environ.get("LT_USERNAME")
194+
197195
if os.environ.get("LT_ACCESS_KEY") is None:
198-
# Enter LT accesskey here if environment variables have not been added
199-
accessToken = "accessToken"
196+
# Enter LT accesskey below if environment variables have not been added
197+
accesskey = "<YOUR_LT_ACCESS_KEY>"
200198
else:
201-
accessToken = os.environ.get("LT_ACCESS_KEY")
199+
accesskey = os.environ.get("LT_ACCESS_KEY")
202200

203-
hub_url = "mobile-hub-internal.lambdatest.com/wd/hub/session"
201+
# grid url
202+
gridUrl = "mobile-hub.lambdatest.com/wd/hub"
204203

205-
url = "https://"+username+":"+accessToken+"@"+hub_url
206-
207-
caps = {
208-
"deviceName": "Roku Express", #We also support "Roku Ultra"
209-
"platformVersion": "11",
210-
"isRealMobile": True,
211-
"platformName": "roku",
212-
"build": "Roku Sample Test",
213-
"app": "APP_URL" #Add app url here
214-
"video": True,
215-
"visual": True,
216-
"devicelog": True
217-
}
218-
t1 = time.time()
219-
run(url, caps)
220-
t2 = time.time()
221-
print("sec:",t2-t1)
204+
# capabilities
205+
desired_cap = getCaps()
206+
url = "https://" + username + ":" + accesskey + "@" + gridUrl
207+
208+
print("Initiating remote driver:")
209+
driver = webdriver.Remote(
210+
options=UiAutomator2Options().load_capabilities(desired_cap),
211+
command_executor=url
212+
)
213+
214+
# run test
215+
print(driver.session_id)
216+
217+
# Simulate remote control actions
218+
driver.execute_script("roku: pressKey", {"key": "Down"})
219+
driver.execute_script("roku: pressKey", {"key": "Down"})
220+
time.sleep(1)
221+
driver.execute_script("roku: pressKey", {"key": "Right"})
222+
driver.execute_script("roku: pressKey", {"key": "Up"})
223+
driver.execute_script("roku: deviceInfo")
224+
time.sleep(1)
225+
driver.execute_script("roku: getApps")
226+
driver.execute_script("roku: pressKey", {"key": "Right"})
227+
228+
driver.quit()
229+
230+
231+
if __name__ == "__main__":
232+
runTest()
222233
```
223234

224235
### Configure the test capabilities
@@ -237,16 +248,17 @@ Please check at the end of the doc.
237248

238249
```python title="main.py"
239250
caps = {
240-
"deviceName": "Roku Express", #We also support "Roku Ultra"
241-
"platformVersion": "11",
242-
"isRealMobile": True,
243-
"platformName": "roku",
244-
"build": "Roku Sample Test",
245-
"app": "APP_URL" #Add app url here
246-
"video": True,
247-
"visual": True,
248-
"devicelog": True
249-
}
251+
"automationName": "Roku",
252+
"deviceName": "Roku Express", #We also support "Roku Ultra"
253+
"platformVersion": "11",
254+
"isRealMobile": True,
255+
"platformName": "roku",
256+
"build": "Roku Sample Test",
257+
"app": "APP_URL" #Add app id here
258+
"visual": True,
259+
"devicelog": True
260+
}
261+
250262
```
251263

252264
:::info Note
@@ -276,17 +288,18 @@ If you are unable to run the automation script with the above mentioned commands
276288

277289
### List of Capabilities supported by Roku:
278290

279-
| KEY | VALUES | CAPABILITY DESCRIPTION |
280-
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
281-
| \*deviceName | TYPE: STRING <br/> `iPhone 13` | Name of the device. |
282-
| isRealDevice | TYPE: BOOLEAN <br/> DEFAULT: TRUE <br/> `video=TRUE` <br/> OR <br/> `video=FALSE` | It makes sure that the device being allocated is a Real device. |
283-
| \*platformName | TYPE: STRING <br/> `ios` | Name of the OS. |
284-
| \*platformVersion | TYPE: STRING <br/> `14` | OS version. |
285-
| build | TYPE: STRING <br/> DEFAULT: Untitled <br/> `build=iOS Small Run` | You can group your tests like a job containing multiple tests. |
286-
| \*app | TYPE: STRING <br/> `app=lt://APP100201061631704657918380` | Accepts App URL returned after uploading an app on the LambdaTest servers. | |
287-
| visual | TYPE: BOOLEAN <br/> DEFAULT: FALSE <br/> `visual=TRUE` <br/> OR <br/> `visual=FALSE` | Command by command screenshots will be recorded at each test step. By default the flag is set as off. Note: test execution time will increase if it’s set as ‘true’. |
288-
| video | TYPE: BOOLEAN <br/> DEFAULT: TRUE <br/> `video=TRUE` <br/> OR <br/> `video=FALSE` | Video recording of the complete screen. |
289-
| devicelog | TYPE: BOOLEAN <br/> DEFAULT: FALSE <br/> `devicelog=TRUE` <br/> OR <br/> `devicelog=FALSE` | Enable Device logs. |
291+
| KEY | VALUES | CAPABILITY DESCRIPTION |
292+
| ---------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
293+
| automationName | TYPE: STRING <br/> `roku` | Tells Appium to use the Roku Appium Driver. |
294+
| *deviceName | TYPE: STRING <br/> `Roku Ultra` | Name of the device. |
295+
| isRealDevice | TYPE: BOOLEAN <br/> DEFAULT: TRUE <br/> `video=TRUE` <br/> OR <br/> `video=FALSE` | It makes sure that the device being allocated is a Real device. |
296+
| *platformName | TYPE: STRING <br/> `roku` | Name of the OS. |
297+
| *platformVersion | TYPE: STRING <br/> `11` | OS version. |
298+
| build | TYPE: STRING <br/> DEFAULT: Untitled <br/> `build=iOS Small Run` | You can group your tests like a job containing multiple tests. |
299+
| *app | TYPE: STRING <br/> `app=lt://APP100201061631704657918380` | Accepts App URL returned after uploading an app on the LambdaTest servers. |
300+
| visual | TYPE: BOOLEAN <br/> DEFAULT: FALSE <br/> `visual=TRUE` <br/> OR <br/> `visual=FALSE` | Command by command screenshots will be recorded at each test step. By default off. |
301+
| video | TYPE: BOOLEAN <br/> DEFAULT: TRUE <br/> `video=TRUE` <br/> OR <br/> `video=FALSE` | Video recording of the complete screen. |
302+
| devicelog | TYPE: BOOLEAN <br/> DEFAULT: FALSE <br/> `devicelog=TRUE` <br/> OR <br/> `devicelog=FALSE` | Enable Device logs. |
290303

291304
Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on the [LambdaTest App Automation Dashboard](https://appautomation.lambdatest.com/build).
292305

0 commit comments

Comments
 (0)