1. Appium 2 Installation
npm i -g appium@next
2. Driver Installation
From Appium 2.0 drivers can be installed/uninstalled or updated independently. For example,
if an update is available for XCUITest then rather than waiting for a new Appium server
release we can update the driver only by using CLI commands.
Install IOS Driver in Appium 2:
appium driver install xcuitest
Install Android Driver in Appium 2:
appium driver install uiautomator2
How to Update Driver:
appium driver update xcuitest
Update Multiple drivers :
appium driver update xcuitest,uiautomator2
How to check all available/Installed drivers
appium driver list
3. Capabilities In Appium 2.0
Now User needs to include the vendor prefix in the non-standard capabilities names.
For Example, if you wish to provide deviceName in capabilities, it should consist of the
vendor prefix “appium:deviceName“.
Appium 1 (Older way):
Earlier in the Appium 1. x version we used to define capabilities using DesiredCapabilities
class to set various properties and preferences that define how an automation session should be
established with a mobile device or an emulator.
DesiredCapabilities androidCaps = new DesiredCapabilities();
androidCaps.setCapability("deviceName", "Pixel XL API 30");
androidCaps.setCapability("automationName", "UIAutomator2");
androidCaps.setCapability("udid", "emulator-5554");
androidCaps.setCapability("platformName", "Android");
androidCaps.setCapability("app",System.getProperty("user.dir") + "/src/test/resources/files/Bilgikolik.apk");
androidCaps.setCapability("appPackage", "com.testapp.app");
androidCaps.setCapability("appActivity", "com.testapp.app");
driver = new AndroidDriver(newURL("http://127.0.0.1:4723"),androidCaps);
Appium 2 Capabilities
In Appium 2, we use UiAutomator2Options class that provides information to Appium about
the desired configuration for the test session. Refer below code.
UiAutomator2Options capabilities = new UiAutomator2Options();
capabilities.setPlatformName("Android").setAutomationName("UIAutomator2")
.setAppPackage("Package Name").setAppActivity("Activity Name")
.setApp("App Path");
AndroidDriver driver = new AndroidDriver(new URL("http://0.0.0.0:4723/"),c
4. Appium Inspector
Appium 2.0 segregated Appium Inspector from Appium Desktop. Also, the Appium team provided
the browser version of the Appium inspector. To test against local servers, you’ll need to
start the server with --allow-cors so that the browser-based version of Appium Inspector can
access the Appium server to start sessions.
5. Changes In Drivers and Classes
SelendroidDriver class is removed.
MobileElement classes including AndroidElement and iOSElement classes are removed. It is recommended
to use WebElement.
@AndroidFindBy(xpath ="//android.widget.TextView[@text='Continue']")
private WebElement Continue;
Mobile By Class has been removed, and AppiumBy Class has been introduced.
Older Way:
driver.findElement(MobileBy.id("loginbutton")).click();
New Way:
driver.findElement(AppiumBy.id("loginbutton")).click();
All locator names in AppiumBy have been aligned to follow the camelCase naming strategy,
e.g. MobileBy.AccessibilityId was changed to AppiumBy.accessibilityId.
Appium Driver is directly inherited from Selenium’s RemoteWebDriver. There is no intermediate
layer between AppiumDriver and RemoteWebDriver.
ResetApp, launch apps, and closeApp methods have been depreciated.
Appium Inspector is split out from Appium Desktop. Appium Inspector can be used with its web
version without downloading anything.
6. TouchAction/MultiTouchAction
From Appium 2.0 both TouchAction and MultiTouchAction class has been depreciated.W3c Action
API will be used for automating gestures. For Example, the double Click Gesture can be achieved using the below code:
driver.executeScript("mobile: doubleClickGesture", ImmutableMap.of(
"elementId", ((RemoteWebElement) element).getId());
Reference Link Click here
What Is New In Appium 2.0?
Selenium 4: Understanding Key Features
1. Enhanced Selenium Grid
The new Selenium Grid comes with Docker support. This will enable developers or testers
to spin up the containers rather than setting up heavy virtual machines. Moreover, it is
redesigned in a way that will allow QAs to deploy the grid on Kubernetes for better scaling.
Managing Selenium Grid is now smooth and easy as there will no longer be any need to set up
and start hubs and nodes separately. Teams or individual testers
can now deploy the grid in three modes:
Standalone mode
Hub and Node
Fully distributed
2. Upgraded Selenium IDE
Most QA engineers using the Selenium tool suite are familiar with the popular record and
playback tool – Selenium IDE. This Selenium IDE was earlier available just as a Firefox add-on.
Later, it got deprecated with the introduction of the latest Firefox versions. This is because
the add-ons in the latest Firefox (ver. 55) were standardized under the Web
Extension mechanism.With Selenium 4, the IDE is revived and now its add-on is available
for major web-browsers like Firefox and Chrome. The add-on for Selenium IDE is now also
available on the MS store.The new Selenium 4 IDE provides some notable features
like:Improved GUI for intuitive user experience.The new IDE also comes bundled with a SIDE tool
aka Selenium IDE runner. It allows QAs to run .side projects on a node.js platform. This
SIDE runner also enables individual QAs to run cross browser tests on local or Cloud Selenium
Grid.Improved control flow mechanism that enables testers to write
better “while” and “if” conditions. The new IDE comes with an enhanced element locator strategy
(Like a backup strategy) which helps locate an element in case the web element couldn’t be located.
It will result in the creation of stable test cases.The code for test cases recorded using Selenium
IDE can be exported in the desired language binding like Java, C#, Python, .NET, and JavaScript.
3. Relative Locators in Selenium 4
Selenium 4 brings an easy way of locating elements with the inclusion of relative locators.
This means testers can now locate specific web elements using intuitive terms that are often
used by users like:
To left of
To right of
Above
Below
The introduction of this new method in Selenium 4 helps locate web elements based on the visual
location relative to other DOM elements. One can refer to this source to learn more about the
implementation of relative locators in detail.
4. Improved Documentation
The documentation section has been revamped significantly with a neat UI for navigating to
the desired section or page. This will help testers and developers find relevant information they need
for a specific tool, language binding, etc.The exhaustive documentation covers information about all
tools and APIs under the Selenium umbrella. This will help individual testers (particularly the beginners)
get acquainted with all the features and prerequisites to get started with automation testing.
5. Support for Chrome Debugging Protocol
Selenium 4 comes with native support for Chrome DevTools Protocol. This means QAs can now
use Chrome development properties like Fetch, Network, Profiler, Performance, Application cache,
and more. QAs can also leverage the APIs offered by Chrome DevTools to simulate poor network
conditions and perform geolocation testing. Using this API will also help developers or QAs to test
and resolve critical bugs for specific web-pages faster and on the fly.
6. Better Window/Tab Management in Selenium 4
There are several instances in test automation wherein one might need to open a particular
link in a new tab or window to perform certain actions. To achieve this in Selenium 3, QAs had
to create a new driver object and then perform the switch operation using the WindowHandle method
to perform subsequent steps. This is set to change in Selenium 4 as it comes with a
new API – newWindow that allows users to create and switch to a new window/tab without creating
a new WebDriver object. Sample
code snippet to open a new window
driver.get("https://www.google.com/");
// Opens a new window and switches to new window
driver.switchTo().newWindow(WindowType.WINDOW);
// Opens BrowserStack homepage in the newly opened window
driver.navigate().to("https://www.browserstack.com/");
Sample code snippet to open a new tab within the same window
driver.get("https://www.google.com/");
// Opens a new tab in existing window
driver.switchTo().newWindow(WindowType.TAB);
// Opens Browserstack homepage in the newly opened tab
driver.navigate().to("https://www.browserstack.com/");
7. Deprecation of Desired Capabilities
Desired Capabilities were primarily used in the test scripts to define the test environment
(browser name, version, operating system) forexecution on the Selenium Grid.
In Selenium 4, capabilities objects are replaced with Options. This means testers now need to create an Options
object, set test requirements, and pass the object to the Driver constructor.
Listed below are the Options objects to be used going forward for defining browser-specific capabilities:
Firefox – FirefoxOptions
Chrome – ChromeOptions
Internet Explorer (IE) – InternetExplorerOptions
Microsoft Edge – EdgeOptions
Safari – SafariOptions
8. Modifications in the Actions Class
Actions class in Selenium is primarily used to simulate input actions from mouse and keyboard on
specific web elements (For eg: Left click, Right click, Double click, etc)
In Selenium 4, several new methods have been added to the Actions class:
click(WebElement)
This method is added to Actions class to replace the moveToElement(onElement).click().
It is used to click on a certain web element.
clickAndHold(WebElement)
This method will replace the moveToElement(onElement).clickAndHold().
It is used to click on an element without releasing the click.
contextClick(WebElement)
This method will replace moveToElement(onElement).contextClick().
It will perform the right click operation.
doubleClick(WebElement)
This method is added to replace moveToElement(element).doubleClick().
It will perform a double click on an element.
release()
Reference Link:- Click here
Subscribe to:
Comments (Atom)