For some of the key essential Tips for Appium and overcome any known issue kindly read this blog.

Appium

Appium is an open-source, cross-platform automation framework that allows testers to write and execute automated tests for mobile applications on iOS and Android devices. It uses the WebDriver protocol to automate interactions with the application’s user interface, allowing testers to simulate user actions such as clicking buttons, entering text, and swiping screens.

For example, let’s say you want to test a mobile app’s login functionality. With Appium, you can write a test script that launches the app, navigates to the login screen, enters valid or invalid credentials, and verifies that the expected result is displayed. This test script can be run across different devices and operating systems, allowing you to test the app’s functionality in a wide variety of scenarios.

Let’s discuss some essential tips to overcome issues during the Appium automation setup.

1. How to specify node and JS location

In some cases, the node and appium’s binary location might be different than the default value. In such cases, you might encounter errors like node installation not found and appium not found. In those occasions first try to find the location of the node and appium using which commands as shown below

$ which node
/opt/homebrew/bin/node
$ which appium
/opt/homebrew/bin/appium

If the appium location is a shortcut then open the location and find the source location. As the AppiumServiceBuilder looks for the main.js of appium which will be usually under the build/lib folder of the appium directory.

And now using this information we can initialize the AppiumServiceBuilder for the custom location as mentioned below.

service = new AppiumServiceBuilder()
				.usingDriverExecutable(new File("/opt/homebrew/bin/node"))
				.withAppiumJS(new File("/opt/homebrew/lib/node_modules/appium/build/lib/main.js"))
				.withIPAddress("127.0.0.1")
				.withArgument (BASEPATH, "/wd/hub")
				.usingPort(4723)
				.build();

2. macOS Appium Startup Issue

In general, to start the appium programmatically we have to define the AppiumServiceBuilder as mentioned above and we have to call the start method of the AppiumServiceBuilder instance. This will start the appium programmatically which will make the automation complete and not rely on any human intervention.

service.start();

But in some cases, in newer Mac devices this doesn’t work, this is due to the tools compatibility issue. So to fix this you need to run the appium services manually in the command line tools as shown below

$ appium -p <Port Number>

3. Encountering UI Element Not Found in Appium? Here’s How to Fix It!

Sometimes, when we try to perform certain actions on UI elements in Appium, we might run into an issue where the element is not found, particularly when switching from one screen to another. This can be attributed to the animation involved during the screen transition and the time it takes for the new screen to become fully active.

Thankfully, there are ways to address this behavior. One approach is to add a slight delay between each command. Another effective method is to utilize the timeout feature of the Driver, as demonstrated below. By implementing these solutions, we can ensure a smoother experience with our Appium tests and avoid the frustration of UI elements not being found.

AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723"), options);;
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
(or)
Thread.sleep(5000);//Between each command where we find this issue.

I hope these essential tips for effective Mobile Testing help to resolve some of the issues that occurred during the development of appium automation.

Happy Coding…..!

Written By
Fareeth John

I’m working as a Sr. Solution Architect in Akamai Technologies. I have more than 13 years of experience in the Mobile app development industry. Worked on different technologies like VR, Augmented reality, OTT, and IoT in iOS, Android, flutter, and other cross-platform apps. Have worked on 45+ apps from scratch which are in the AppStore and PlayStore. My knowledge of mobile development including design/architecting solutions, app development, knowledge around backend systems,  cloud computing, CDN, Test Automation, CI/CD, Frida Pentesting, and finding mobile app vulnerabilities

Leave a Reply

Your email address will not be published. Required fields are marked *