Selenide-Appium – Mutated Java Appium Client [Testμ 2023]

Selenide-Appium – Mutated Java Appium Client [Testμ 2023]

In this session, our speaker, Amuthan Sakhtivel, walked us through Selenide-Appium — a game-changing open-source library built on Appium Java Client. We discovered how Selenide-Appium can significantly reduce the script development time, giving more room to focus on what truly matters. The session ended with an interactive demo on Selenide-Appium and a discussion of its integration with cloud-based platforms like LambdaTest.

About the Speaker

Amuthan Sakhtivel is a passionate advocate for testing, Java, open source, and education. He’s not only a contributor to projects like Selenide and Selenide-Appium but also a knowledge sharer through his YouTube channel and technical blogs. Currently, he works with Clipboard Health as a Staff Software Engineer.

If you couldn’t catch all the sessions live, don’t worry! You can access the recordings at your convenience by visiting the LambdaTest YouTube Channel.

Why Selenide-Appium?

Getting started with the session, Amuthan talked about why he prefers Selenide-Appium over Appium in his testing efforts. He highlighted Selenide’s advantages, such as being free, open source, and built on top of Appium. Amuthan emphasized Selenide’s concise and readable APIs, which simplify the code. Additionally, Selenide handles common problems and exceptions, ensuring stability.

Further, he highlighted that Selenide simplifies handling common mobile app testing challenges, such as timeouts, Ajax calls, screenshot capture, and state element reference exceptions. These advantages collectively allow developers to focus primarily on their app’s business logic, sparing them from diving into the intricacies of low-level interactions.

Amuthan discussed how Selenide offers a higher-level testing library with built-in assertions and waiting conditions compared to Appium, allowing testers to focus on writing business logic while simplifying interactions and automating many aspects of testing.

Selenide-Appium for Mobile App Testing

Before showing the live demo of Selenide-Appium in action, Amuthan discussed several aspects related to mobile app testing and how Selenide-Appium simplifies the process. This approach improves code quality, readability, and maintainability for mobile app developers.

Smart Wait from Selenide-Appium:

Amuthan emphasized the complexities of waiting for elements in Appium, including the need for explicit timeout declarations and specific conditions. He introduced Selenide’s should and shouldHave methods as powerful tools to simplify this process.

By incorporating these methods into test scripts, developers can express waiting conditions in a more human-readable format. This approach eliminates much of the boilerplate code typically required for handling element visibility and other conditions during testing. He mentioned that Selenide allows users to focus on the intent of their tests rather than the mechanics of waiting for elements.

Working with Deep Links:

The challenge of launching deep links in mobile app testing lies in the differences between Android and iOS implementations. Amuthan elaborated on how Selenide-Appium acts as an abstraction layer, shielding users from these platform-specific complexities.

With Selenide-Appium, developers can consistently launch deep links across various platforms and devices using a unified approach. This abstraction empowers testers to avoid the intricacies of different platform-specific code, enhancing test script clarity and maintainability.

Additional Selectors:

Amuthan addressed the length and error-proneness of using XPath expressions for element selection in Appium. He introduced Selenide’s byAttribute mechanism, which simplifies the selection of elements based on attributes.

This alternative to crafting intricate XPath expressions results in cleaner and more reliable test code. Developers can easily adopt this approach to select elements with specific attributes, improving the maintainability of their test scripts.

Hide Keyboard:

Managing the keyboard during mobile app testing often requires creating platform-specific code. Amuthan highlighted how Selenide abstracts keyboard interactions, offering a platform-agnostic method for hiding the keyboard.

This abstraction streamlines test scripts and ensures consistent behavior across Android and iOS, irrespective of the underlying platform intricacies. Testers can now focus on the logic of their tests without being burdened by platform-specific keyboard handling.

Other Native Events:

Amuthan discussed the complexities involved in performing native events, such as tapping or double-tapping, in Appium. He demonstrated how Selenide simplifies these interactions, providing concise and readable code for actions like tapping, double-tapping, and swiping.

Selenide’s capabilities enable testers to execute these native events without delving into the intricacies of low-level code, enhancing the efficiency and readability of test scripts.

Combined Attribute:

Selenide introduces the CombinedBy class for defining custom attributes. Amuthan explained how this feature enables users to create custom attribute conditions tailored to different platforms.

By handling platform-specific logic internally, Selenide streamlines element selection and reduces the need for extensive platform-specific conditional code. This approach simplifies the process of selecting elements with specific attributes, promoting code simplicity and maintainability.

Dynamic Locators:

Dynamic locators, particularly when involving index-based selections, can pose challenges in Appium. Amuthan illustrated how Selenide simplifies dynamic locator handling by allowing users to define dynamic locators using a single CombinedBy instance.

This capability reduces the complexity of managing dynamic locators and minimizes the need for conditional code in test scripts. Developers can now create more robust and maintainable tests, even when dealing with dynamically changing elements.

Scroll/Swipe to Element:

Scrolling or swiping to locate elements in Appium can be intricate, often requiring multiple steps and error handling. Amuthan highlighted that Selenide-Appium offers built-in methods to simplify these interactions.

With Selenide-Appium, testers can efficiently scroll or swipe to elements, significantly enhancing the ease of locating and interacting with elements within the app. This capability enhances the overall robustness and readability of test scripts.

Triple Click — Custom Command:

Amuthan discussed the flexibility of Selenide-Appium in creating custom commands to address unique testing scenarios. He showcased how users can implement custom commands by extending Selenide’s functionality.

This feature allows customized interactions, such as triple-clicking, tailored to specific testing requirements. Testers can seamlessly adapt the framework to suit their unique testing needs, thereby expanding the scope and versatility of their test scripts.

A Live Masterclass on Selenide-Appium

Amutha gave a comprehensive demo on Selenide-Appium, highlighting the advantages and capabilities of Selenide-Appium in simplifying mobile app testing and promoting efficient test automation. This is the stepwise breakdown of the demo he presented:

1.Project Setup: Amuthan initiated the demo by showcasing a Maven project setup with relevant dependencies. He mentioned the inclusion of dependencies for JUnit Jupiter, the chosen testing framework, and highlighted that TestNG could also be used. This project setup formed the foundation for the subsequent test script.

2.Test Use Case: The use case chosen by Amuthan for the demo involved interacting with a mobile app. The scenario was to navigate through the app’s screens, click on specific elements, scroll to find elements, perform a custom triple-click action, and validate the result. This use case demonstrated various aspects of mobile app testing.

3.Selenide-Appium’s Simplifications: Throughout the demo, Amuthan emphasized how Selenide-Appium simplifies the mobile app testing process, making it more efficient and readable. He highlighted that Selenide-Appium abstracts many complexities, enabling testers to focus on the intent of their tests rather than dealing with low-level details.

4.Element Locators: Amuthan showcased how Selenide-Appium simplifies element locators. He used a straightforward approach to locate elements using text-based selectors (e.g., by.text(“Next”)) instead of manually crafting complex XPath expressions. This approach significantly reduced code noise and enhanced readability.

5.Selenide’s Page Object Model: Amuthan introduced Selenide’s Page Object Model, emphasizing its ease of use compared to the traditional Page Factory. He demonstrated how Selenide’s Screen object abstracts element initialization and eliminates the need for explicit Page Factory calls. This approach simplifies the organization of test code and reduces the risk of null pointer exceptions.

6.Custom Command Creation: In the demo, Amuthan showed how to create a custom command called “triple click” to address a unique testing scenario. While a simple triple click action might not be common, he explained that users could create custom commands to suit specific testing requirements. Custom commands were implemented by extending Selenide’s functionality and could be seamlessly integrated into test scripts.

7.Automated Test Script: Amuthan systematically built the script, from setting up the test environment to defining test steps. He demonstrated how Selenide’s conditions (e.g., should.be(visible)) could be used to wait for and interact with elements without writing complex explicit waits or condition checks. The script followed the Page Object Model pattern, ensuring a clean code structure.

8.Running Tests on Different Platforms: In the demo, Amuthan showed how to configure and run the same test on different platforms, such as locally and on-cloud providers like LambdaTest. This flexibility allows testers to execute tests on various devices and environments effortlessly.

9.Real-Time Test Execution: Amuthan conducted a real-time test execution, showcasing how the automated script seamlessly interacted with the mobile app. He emphasized that Selenide-Appium abstracts many low-level interactions with the app, making test execution straightforward. This abstraction enables testers to focus on the core test scenarios and business logic without getting entangled in the complexities of mobile app interaction.

10.LambdaTest Integration: In a brief demo of LambdaTest integration, Amuthan configured platform-specific details to run tests on it. This highlighted how Selenide-Appium can easily integrate with cloud providers, offering testers the flexibility to run tests in the cloud. This integration extends the reach of testing to a wide range of devices and environments, ensuring comprehensive test coverage and compatibility.

Amuthan wrapped up this insightful yet interactive session with this demo. After the end of the session, he moved on to answer some questions from the audience.

Time for Some Q&A

Q. How does the mutation of the Java Appium Client in Selenide-Appium enhance the capabilities and performance of mobile test automation?

Amuthan: It makes testing easy without slowing down performance. You save time writing tests, and they’re easier to read. The Java Appium client in Selenide-Appium provides shortcuts so you can focus on testing, not technical details. It doesn’t affect performance; it improves code quality.

Q. What impact does Selenide-Appium have on the readability and structure of test scripts?

Amuthan: I’ve been using Appium for a long time, and I’ve seen how it evolves rapidly, which can be challenging to keep up with. Ensuring code works across different devices with varying specifications is complex. However, in our organization, adopting Selenide-Appium has significantly improved test readability and our testing speed. Before, we could only create 1 or 2 scripts daily, but now we manage 4 to 8 scripts daily, making our testing process faster and more efficient.

Q. Could you discuss a scenario where this combination facilitated cross-platform testing, saving time and effort?

Amuthan: Yes. Selenide can automate Android and iOS, and I can personally vouch for its effectiveness. I’ve used it in my personal and office projects, which has consistently saved us a lot of time when creating tests. I highly recommend giving it a try.

Q. Can you elaborate on some key mutations or enhancements that set Selenide-Appium apart from the traditional Appium Client?

Amuthan: Sure, we can call these enhancements “mutations.” Without altering Appium itself, we’ve crafted adaptable wrappers. Launching the app is simplified using provider classes and the Webdriver provider interface. Our wrappers manage sessions and support parallel test execution, improving code clarity and readability. Plus, you can effortlessly switch back to Appium using AppiumDriverRunner.getDriver() if Selenide lacks a specific capability.

Have a question? Feel free to drop it on the LamdaTest Community.