This is a one of the kind of automation that is used to validate a product UI elements and interact with these UI component to perform any kind of action such as a validation of UI elements working correctly as it is expected. In this UI topic, we are speaking about Device Android / iOS application.
As you all know Device application are running in different operating system. There are two main types of operating system Android, iOS. of course , there is also a hybrid type which is running in Both IOS and Android.
Native Apps
- Android – Apps
- Android apps are called Native apps which means they are built for a specific operating system – which is Android. This types of apps are downloaded from play store and installed only in Android operating system.
- IOS – Apps
- IOS apps are called Native apps which means they are built for a specific operating system – which is iOS. This types of apps are downloaded from App Store and installed only in IOS operating system
Hybrid – Apps
Hybrid apps, however, are built to work across any operating system and share the same codebase. This means wrapping client code in a native shell or container. that could let the app to be installed on any device support Android or IOS.
Mobile Web Apps
- These are apps running in browsers like [safari for ios, chrome and other build in for android]
Driver & Capabilities
Capabilities are the most significant thing to determine as the driver is initialized for Automation purpose. The capability determine a lo of elements about the driver be used in the automation purpose.
#Android
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android"); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "4.4"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator"); capabilities.setCapability(MobileCapabilityType.APP, myApp);
#myApp - refers .apk file
Figure 1.1 – Capability for Android
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS"); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator"); capabilities.setCapability(MobileCapabilityType.APP, myApp)
#myapp - refers .ipa file
Figure 1.2 – Capability for IOS
Web Driver
It is an API and protocol that defines a language-neutral interface for controlling the behaviours of web browsers. Each browser is backed by a specific WebDriver implementation, called a driver.The driver is the component responsible for handling a communication to and from Selenium and the browser. Before you can start writing Selenium code, the following three important things are mandatory to do e of choice,
- You have to install the language bindings libraries for your languag
- The browser you want to use,
- And the driver for that browser.
Adding Dependency For Selenium-Java
The dependency for maven Java project to add the dependency, get the dependency from a Maven Repository page. The dependency of Selenium Java as follow
Figure 1.1 Adding Dependency Selenium-Java
Driver
Driver is an element that is used to interact to a dedicated browser which belongs to. As per the need of our preference, create a driver stating the nature of browser either chrome, Firefox, edge, safari, internet explore and so and so forth.
Driver Functions
Once the driver has been declared with the browser we wish to work on, all related function that could let us to interact with the web are accessible. some of the functions are as follow
- driver.get(“URL”) : – Used to open the page indicated in the URL
- WebElement element : – Used to store a web element
- driver.findElement(By.name(“my-text”)) : – Used to find an element by the name “my-text”
- driver.findElement(By.cssSelector(“button”)) : – Used to find an element by CSS selector
- driver.getTitle() : – Used to get the title of the web page.
- driver.getCurrentUrl() : – Used to get a URL of an open page.
- element.sendKeys(“Selenium”) : – Send values to the element identified
- element.getText() : – Used to get a text of an element that is indicated
- submitButton.click(): – Used to perform a click action against an element.
- driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500)) : – This is an implicit wait for a certain time indicated
- Waiting until the element revealed is displayed: – Like wait.until(d -> revealed.isDisplayed())
- driver.quit() : – Used to close the browser
- Many more