The difference between web and mobile test automation drivers
The Appium server gives access to Appium users to control functions of the device under the test, such as installation and removal of an application during the test session. The same client implementations exist for Selenium. But a Selenium server is required for distributed test execution only if we need to install Selenium grid.
To clarify, Selenium supports major browsers running in the main desktop operating systems. Appium supports a large variety of iOS and Android devices, for the officially supported versions of iOS and Android. In addition, Appium can provide the automation of MS Windows applications. On the other hand, there is a difference in efforts, which are required to configure the infrastructure for Appium and Selenium testing. To conduct Appium testing you need to install nodeJS, install Appium, configure SDK and specific device drivers and frameworks. For a Selenium testing case, there are not so many steps to configure the environment for tests developments and execution, unless you install the Selenium server to run tests against Selenium Grid. Appium and Selenium stacks diagram are shown on the pictures below.
The example of using both frameworks for mobile web automation
The common basis in both frameworks makes it possible to use them together for web and mobile test automation, despite the differences listed above. When we need to test a web application in the mobile browser, we can use both Appium and Selenium frameworks and they will complement each other in one test. Below you will see a link to a simple test in GIT, for example, which opens a page of the Amazon.com site in the Android Chrome browser on a mobile device.
Test codes use both Selenium and Appium libraries to interact with the browser on a mobile device. Appium client objects are used to initialize a device driver, define the Android Chrome browser and control it. Selenium is used to define “Desired capabilities” object, which controls the device driver, mobile browser and interacts with the web application (in the test, the Amazon.com website is used), by means of the Selenium object “By”. Using these objects gives access to the web elements of the mobile browser.
The test is executed on the SeeTest platform – cloud-based platform, offering a great number of browsers and mobile devices for development and web and mobile test automation. For comparison, there is the test, that opens cloud.seetest.io website page in the Google Chrome browser on the Mac platform, then finds a few links on the page and clicks on the links found. In this case, only Selenium objects are used, which control the remote browser on the SeeTest cloud platform and perform actions specified in the test. Check out the code for the test in the link below.
The second test is also executed on the SeeTest platform and is ready to be run. Both tests can be downloaded, compiled and launched. Use ‘mvn clean install’ command for it. As both tests are supposed to be executed on the SeeTest platform, don’t forget to add the access key from your SeeTest account to the system variables, before you launch tests.
The first example shown above illustrates both Appium and Selenium testing and is one of the examples of the web and mobile test automation. This case happens when a web application is required to be run in both the desktop and mobile browsers, which often happens nowadays.
An example of using Appium and Selenium for automation of native mobile applications
Besides a requirement to support various browsers on multiple mobile and desktop platforms, modern applications may have multiple types of client: web, desktop, mobile, which in turn can be run on diverse hardware platforms under various operating systems. For a QA engineer, above all, it means the necessity to conduct tests on all possible combinations of hardware, OS, and browser. For instance, a possible use case, when two different clients are used, is the case when a user from the mobile client performs some action and another user from the web client gets the result of this action or vice versa.
The example of such a case is a post in a social network which has to be checked by different clients. Another example is a chat, where a user from a mobile client sends a message and a user from a web client receives the message or vice versa. From the test case perspective, it will have to imitate the interaction between the two types of clients: mobile and web client. So in one test both Appium and Selenium frameworks will be used and this type of tests combines both Selenium and Appium testing. In this test, Appium objects are used to manage the mobile device, while Selenium objects are used to manage and interact with the browser on the desktop platform. A test is also supposed to be executed on the SeeTest cloud service.
As for implementations, tests for these clients can be written in separate modules and executed in parallel using SeeTest for the corresponding instances. In this example, Selenium and Appium complement each other. This is another example of web and mobile test automation.
Is the Appium framework based on Selenium or not?
And finally here’s a note about automation of native mobile applications. When we write UI tests for them and interact with the elements on mobile pages, we access them through the object which is an instance of the class io.appium.java_client.MobileElement extended from the org.openqa.selenium.remote.RemoteWebElement. This means, that tests for the native mobile applications will use Selenium implicitly to access mobile pages elements.
To sum up, Selenium and Appium are not isolated frameworks, which can be used only for web and mobile test automation correspondingly, these frameworks can be used together in one test for testing web applications in the mobile browser and for the implementation of complex test cases, which involve interactions with web and mobile clients. All these test cases can be easily executed on the SeeTest platform, which in short provides a variety of mobile devices and browsers for tests. Furthermore, SeeTest is ranked at the top among cloud platforms for conducting web and mobile test automation.
In order to see how it all works first hand, click here for a free trial.