App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide How to run Appium Tests on macOS?

How to run Appium Tests on macOS?

By Mohammed Waseem, Community Contributor -

Appium is an automated mobile application testing framework that can work with hybrid, native, and web applications on various operating systems, such as Windows and macOS, to run in an Android and iOS environment. Like in every phase of the SDLC, mobile testing requires the right tools and frameworks. Appium is one of the most widely used frameworks that facilitate fast and accurate results, making it quite handy in a tester’s toolkit.

This quick guide article will help you learn and simplify the few intricacies you can use to set up and run Appium tests on macOS using BrowserStack. 

How to setup Appium on Mac?

To step and run an Appium test on macOS, refer to the following 9 steps:

  1. Install the dependencies, including Java, Maven, Node.js, Xcode, And appium. 
  2. Once you have installed all the dependencies, make sure you set the path variables in the bash profile for each of the dependencies. 
  3. Sign in to Xcode with your apple developer account.
  4. Open the webdriveragent project from the Appium CLI path and change the bundle ID to io.appium.WebDriverAgentRunner.
  5. Change the target to webdriveragent runner and build the project. 
  6. Open any IDE, and create a Maven Project.
  7. Add all the required Appium dependencies, and declare desired capabilities.
  8. Start the Appium server
  9. Initiate iOSdriver and run your code. 

Running Appium Tests on Browserstack 

To eliminate the hassle that you might have to face with the conventional Appium tests on macOS, you can follow the steps below to run the Appium tests on macOS using BrowserStack.

Step 1. Upload your test application on BrowserStack App Automate. You can use the following script written in Python, which will upload the application to the servers. 

Step 2. You can directly upload your application on Browserstack App Automate, as shown in the image below. Upload your application on Browserstack App Automate

Step 3. Once you have uploaded the application, you will get a code you can write in your test script shown in step 2. 

Step 4. Create a Appium test script and change the desired capabilities to the ones you require.

Step 5. If you are confused about your application’s capabilities, you can use the Appium capability generator from BrowserStack for easier access. 

Step 6. In the following script, we will open the uploaded application and find a web element, enter keys and assert based on responses from the search. 

[python]

from appium import webdriver

from appium.webdriver.common.mobileby import MobileBy

from selenium.webdriver.support.ui import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

import time




desired_cap = {

    # Set your access credentials

    "browserstack.user": "XXXXXXXXXXXXXXXXXXXXX",

    "browserstack.key": "XXXXXXXXXXXXXXXXXXXXX",




    # Set URL of the application under test Generated from the JSON Response

    "app": "bs://c700ce60cf13ae8ed97705a55b8e022f13c5827c",




    # Specify device and os_version for testing

    "device": "iPhone 14",

    "os_version": "16",




    # Set other BrowserStack capabilities

    "project": "Localization Testing",

    "build": "build-1",

    "name": "first_test",




    # set the language capabilities

    "language": "es",

    "locale": "ES"

}




# Initialize the remote Webdriver using BrowserStack remote URL

# and desired capabilities defined above

driver = webdriver.Remote(

    command_executor="http://hub-cloud.browserstack.com/wd/hub",

    desired_capabilities=desired_cap

)

# Test case for the BrowserStack sample Android app.

# If you have uploaded your app, update the test case here.

search_element = WebDriverWait(driver, 30).until(

    EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID, "Search Wikipedia"))

)

search_element.click()

search_input = WebDriverWait(driver, 30).until(

    EC.element_to_be_clickable(

        (MobileBy.ID, "org.wikipedia.alpha:id/search_src_text"))

)

search_input.send_keys("BrowserStack")

time.sleep(5)

search_results = driver.find_elements(MobileBy.CLASS_NAME, "android.widget.TextView")

assert (len(search_results) > 0)




# Invoke driver.quit() after the test is done to indicate that the test is completed.

driver.quit()

[/python]

Step 7. After you run the script, you can monitor the progress on the dashboard and get the detailed report with the Appium logs on BrowserStack.  

Appium logs on BrowserStack

Conclusion

  • To run a hassle-free Appium Mac setup, you must install all the dependencies and set up your test environment efficiently. 
  • For more device options and lesser environment setup worries, you can rely on BrowserStack App Automate and use various devices, OS, browser versions, etc.

Run AppiumTest on Real Devices

Tags
Appium Automation Testing

Featured Articles

How to run Appium iOS Tests on Real Devices?

XPath in Appium: Tutorial

Curated for all your Testing Needs

Actionable Insights, Tips, & Tutorials delivered in your Inbox
By subscribing , you agree to our Privacy Policy.
thank you illustration

Thank you for Subscribing!

Expect a curated list of guides shortly.