Skip to content

Commit a8a6d5e

Browse files
authored
Updated Python With Appium READ.ME File (#2)
* Updated Python With Appium READ.ME File * Updated Python With Appium READ.ME File * Updated Python With Appium READ.ME File * Updated Android Sample File * Updated Sample iOS File * Updated Python With Appium READ.ME File * Updated Python With Appium README File
1 parent 3a860cc commit a8a6d5e

File tree

3 files changed

+201
-20
lines changed

3 files changed

+201
-20
lines changed

README.md

Lines changed: 199 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
1-
# LT_Python_Appium
2-
Sample repo to run app automation on real device on LambdaTest
1+
# Python With Appium ![pw](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python&logoColor=blue)
32

4-
## Pre-requisites
3+
<p align="center">
4+
<img height="500" src="https://user-images.githubusercontent.com/95698164/171858189-9de5d3ef-f177-49ac-9de6-6edb3441740b.png">
5+
</p>
6+
7+
<p align="center">
8+
<a href="https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python" target="_bank">Blog</a>
9+
&nbsp; &#8901; &nbsp;
10+
<a href="https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python" target="_bank">Docs</a>
11+
&nbsp; &#8901; &nbsp;
12+
<a href="https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python" target="_bank">Learning Hub</a>
13+
&nbsp; &#8901; &nbsp;
14+
<a href="https://www.lambdatest.com/newsletter/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python" target="_bank">Newsletter</a>
15+
&nbsp; &#8901; &nbsp;
16+
<a href="https://www.lambdatest.com/certifications/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python" target="_bank">Certifications</a>
17+
&nbsp; &#8901; &nbsp;
18+
<a href="https://www.youtube.com/c/LambdaTest" target="_bank">YouTube</a>
19+
</p>
20+
&emsp;
21+
&emsp;
22+
&emsp;
23+
24+
*Appium is a tool for automating native, mobile web, and hybrid applications on iOS, Android, and Windows platforms. It supports iOS native apps written in Objective-C or Swift and Android native apps written in Java or Kotlin. It also supports mobile web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome or the built-in 'Browser' app on Android). Perform Appium automation tests on [LambdaTest's online cloud](https://www.lambdatest.com/appium-mobile-testing).*
25+
26+
*Learn the basics of [Appium testing on the LambdaTest platform](https://www.lambdatest.com/support/docs/getting-started-with-appium-testing/).*
527

6-
---
28+
[<img height="53" width="200" src="https://user-images.githubusercontent.com/70570645/171866795-52c11b49-0728-4229-b073-4b704209ddde.png">](https://accounts.lambdatest.com/register)
29+
30+
## Table of Contents
31+
32+
* [Pre-requisites](#pre-requisites)
33+
* [Run Your First Test](#run-your-first-test)
34+
* [Executing The Tests](#executing-the-tests)
35+
36+
## Pre-requisites
737

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

@@ -12,51 +42,202 @@ Before you can start performing App automation testing with Appium, you would ne
1242

1343
### Clone The Sample Project
1444

15-
**Step-1:** Clone the LambdaTest's [LT-appium-python](https://github.com/LambdaTest/Python-UnitTest-Selenium) and navigate to the code directory as shown below:
45+
Clone the LambdaTests [LT-appium-python](https://github.com/LambdaTest/Python-UnitTest-Selenium) and navigate to the code directory as shown below:
1646

1747
```bash
1848
git clone https://github.com/LambdaTest/LT-appium-python
1949
cd LT-appium-python
2050
```
2151

22-
2352
### Setting Up Your Authentication
2453

2554
Make sure you have your LambdaTest credentials with you to run test automation scripts on LambdaTest. To obtain your access credentials, [purchase a plan](https://billing.lambdatest.com/billing/plans) or access the [Automation Dashboard](https://appautomation.lambdatest.com/).
2655

27-
**Step-2:** Set LambdaTest `Username` and `Access Key` in environment variables.
56+
Set LambdaTest `Username` and `Access Key` in environment variables.
2857

29-
```bash
30-
export LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
58+
**For Linux/macOS:**
59+
60+
```js
61+
export LT_USERNAME="YOUR_LAMBDATEST_USERNAME" \
3162
export LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"
3263
```
64+
65+
**For Windows:**
3366

67+
```js
68+
set LT_USERNAME="YOUR_LAMBDATEST_USERNAME" `
69+
set LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"
70+
```
71+
3472
### Upload Your Application
3573

3674
**Step-3:** Upload your **_iOS_** application (.ipa file) or **_android_** application (.apk 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:
3775

38-
```bash
39-
curl -u "YOUR_LAMBDATEST_USERNAME":"YOUR_LAMBDATEST_ACCESS_KEY" \
76+
**Using App File:**
77+
78+
**Linux/macOS:**
79+
80+
```js
81+
curl -u "YOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY" \
4082
--location --request POST 'https://manual-api.lambdatest.com/app/upload/realDevice' \
4183
--form 'name="Android_App"' \
4284
--form 'appFile=@"/Users/macuser/Downloads/proverbial_android.apk"'
4385
```
4486

45-
> **Note:**
46-
>
47-
> - If you do not have any **.apk** or **.ipa** file, you can run your sample tests on LambdaTest by using our sample [Android app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android.apk) or sample [iOS app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_ios.ipa).
48-
> - Response of above cURL will be a **JSON** object containing the `App URL` of the format - <lt://APP123456789123456789> and will be used in the next step.
87+
**Windows:**
88+
89+
```js
90+
curl -u "YOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -F "appFile=@"/Users/macuser/Downloads/proverbial_android.apk""
91+
```
92+
93+
**Using App URL:**
94+
95+
**Linux/macOS:**
96+
97+
```js
98+
curl -u "YOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY" \
99+
--location --request POST 'https://manual-api.lambdatest.com/app/upload/realDevice' \
100+
--form 'name="Android_App"' \
101+
--form 'url="https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android.apk"'
102+
```
103+
104+
**For Windows:**
105+
106+
```js
107+
curl -u "YOUR_LAMBDATEST_USERNAME:YOUR_LAMBDATEST_ACCESS_KEY" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -d "{"url":"https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android.apk","name":"sample.apk"}"
108+
```
109+
110+
**Tip:**
111+
112+
- If you do not have any **.apk** or **.ipa** file, you can run your sample tests on LambdaTest by using our sample :link: [Android app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android.apk) or sample :link: [iOS app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_ios.ipa).
113+
- Response of above cURL will be a **JSON** object containing the `App URL` of the format - <lt://APP123456789123456789> and will be used in the next step.
114+
115+
## Run Your First Test
116+
117+
Once you are done with the above-mentioned steps, you can initiate your first Python test on LambdaTest.
118+
119+
**Test Scenario:** Check out [Android.py](https://github.com/LambdaTest/LT-appium-python/blob/master/android.py) file to view the sample test script for android and [iOS.py](https://github.com/LambdaTest/LT-appium-python/blob/master/ios.py) for iOS.
49120

50-
### Executing The Tests
121+
### Configuring Your Test Capabilities
51122

52-
**Step-4:** Run the following command in the directory where your project has been saved to execute your build.
123+
You can update your custom capabilities in test scripts. In this sample project, we are passing platform name, platform version, device name and app url (generated earlier) along with other capabilities like build name and test name via capabilities object. The capabilities object in the sample code are defined as:
124+
125+
<Tabs className="docs__val">
126+
127+
<TabItem value="ios-config" label="iOS" default>
128+
129+
```python title="iOS(.ipa)"
130+
desired_caps = {
131+
"deviceName":"iPhone 12",
132+
"platformName":"ios",
133+
"platformVersion":"14",
134+
"isRealMobile":True,
135+
"app":"YOUR_APP_URL",
136+
"build":"Python Vanilla iOS",
137+
"name":"Sample Test - Python",
138+
"network":True,
139+
"visual":True,
140+
"video":True
141+
}
142+
```
143+
144+
</TabItem>
145+
<TabItem value="android-config" label="Android" default>
146+
147+
```python title="Android(.apk)"
148+
desired_caps = {
149+
"deviceName":"Galaxy S20",
150+
"platformName":"Android",
151+
"platformVersion":"10",
152+
"app":"YOUR_APP_URL",
153+
"isRealMobile":True,
154+
"build":"Python Vanilla Android",
155+
"name":"Sample Test - Python",
156+
"network":True,
157+
"visual":True,
158+
"video":True
159+
}
160+
```
161+
162+
</TabItem>
163+
164+
</Tabs>
165+
166+
**Info Note:**
167+
168+
- You must add the generated **APP_URL** to the `"app"` capability in the config file.
169+
- You can generate capabilities for your test requirements with the help of our inbuilt **[Capabilities Generator tool](https://www.lambdatest.com/capabilities-generator/beta/index.html)**. A more Detailed Capability Guide is available [here](https://www.lambdatest.com/support/docs/desired-capabilities-in-appium/).
170+
171+
## Executing The Tests
172+
173+
Run the following command in the directory where your project has been saved to execute your build.
174+
175+
<Tabs className="docs__val">
176+
177+
<TabItem value="ios" label="iOS" default>
53178

54179
```bash
55180
python3 ios.py
56181
```
57182

183+
</TabItem>
184+
185+
<TabItem value="android" label="Android" default>
186+
58187
```bash
59188
python3 android.py
60189
```
61190

62-
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).
191+
</TabItem>
192+
193+
</Tabs>
194+
195+
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).
196+
197+
## Additional Links
198+
199+
- [Advanced Configuration for Capabilities](https://www.lambdatest.com/support/docs/desired-capabilities-in-appium/)
200+
- [How to test locally hosted apps](https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/)
201+
- [How to integrate LambdaTest with CI/CD](https://www.lambdatest.com/support/docs/integrations-with-ci-cd-tools/)
202+
203+
## Documentation & Resources :books:
204+
205+
Visit the following links to learn more about LambdaTest's features, setup and tutorials around test automation, mobile app testing, responsive testing, and manual testing.
206+
207+
* [LambdaTest Documentation](https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python)
208+
* [LambdaTest Blog](https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python)
209+
* [LambdaTest Learning Hub](https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python)
210+
211+
## LambdaTest Community :busts_in_silhouette:
212+
213+
The [LambdaTest Community](https://community.lambdatest.com/) allows people to interact with tech enthusiasts. Connect, ask questions, and learn from tech-savvy people. Discuss best practises in web development, testing, and DevOps with professionals from across the globe 🌎
214+
215+
## What's New At LambdaTest ❓
216+
217+
To stay updated with the latest features and product add-ons, visit [Changelog](https://changelog.lambdatest.com/)
218+
219+
## About LambdaTest
220+
221+
[LambdaTest](https://www.lambdatest.com) is a leading test execution and orchestration platform that is fast, reliable, scalable, and secure. It allows users to run both manual and automated testing of web and mobile apps across 3000+ different browsers, operating systems, and real device combinations. Using LambdaTest, businesses can ensure quicker developer feedback and hence achieve faster go to market. Over 500 enterprises and 1 Million + users across 130+ countries rely on LambdaTest for their testing needs.
222+
223+
### Features
224+
225+
* Run Selenium, Cypress, Puppeteer, Playwright, and Appium automation tests across 3000+ real desktop and mobile environments.
226+
* Real-time cross browser testing on 3000+ environments.
227+
* Test on Real device cloud
228+
* Blazing fast test automation with HyperExecute
229+
* Accelerate testing, shorten job times and get faster feedback on code changes with Test At Scale.
230+
* Smart Visual Regression Testing on cloud
231+
* 120+ third-party integrations with your favorite tool for CI/CD, Project Management, Codeless Automation, and more.
232+
* Automated Screenshot testing across multiple browsers in a single click.
233+
* Local testing of web and mobile apps.
234+
* Online Accessibility Testing across 3000+ desktop and mobile browsers, browser versions, and operating systems.
235+
* Geolocation testing of web and mobile apps across 53+ countries.
236+
* LT Browser - for responsive testing across 50+ pre-installed mobile, tablets, desktop, and laptop viewports
237+
238+
[<img height="53" width="200" src="https://user-images.githubusercontent.com/70570645/171866795-52c11b49-0728-4229-b073-4b704209ddde.png">](https://accounts.lambdatest.com/register)
239+
240+
## We are here to help you :headphones:
241+
242+
* Got a query? we are available 24x7 to help. [Contact Us](support@lambdatest.com)
243+
* For more info, visit - [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python)

android.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def startingTest():
2929
accesskey = os.environ.get("LT_ACCESS_KEY")
3030

3131
try:
32-
driver = webdriver.Remote(desired_capabilities=desired_caps, command_executor="https://"+username+":"+accesskey+"@beta-hub.lambdatest.com/wd/hub")
32+
driver = webdriver.Remote(desired_capabilities=desired_caps, command_executor="https://"+username+":"+accesskey+"@mobile-hub.lambdatest.com/wd/hub")
3333
colorElement = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ID,"com.lambdatest.proverbial:id/color")))
3434
colorElement.click()
3535

ios.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def startingTest():
2929
accesskey = os.environ.get("LT_ACCESS_KEY")
3030

3131
try:
32-
driver = webdriver.Remote(desired_capabilities=desired_caps, command_executor="https://"+username+":"+accesskey+"@beta-hub.lambdatest.com/wd/hub")
32+
driver = webdriver.Remote(desired_capabilities=desired_caps, command_executor="https://"+username+":"+accesskey+"@mobile-hub.lambdatest.com/wd/hub")
3333
time.sleep(3)
3434
colorElement = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID,"color")))
3535
colorElement.click()

0 commit comments

Comments
 (0)