alewang / java-client

Java language binding for writing Appium Tests, conforms to Mobile JSON Wire Protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java-client

Java language binding for writing Appium Tests, conforms to Mobile JSON Wire Protocol

Depends upon the Selenium Java client library, available here

Download the jar from Maven or add the following to pom.xml:

<dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>3.3.0</version>
</dependency>

It currently depends on selenium-java 2.48.2. If it is necessary to use another version of Selenium then you can configure pom.xml as follows:

<dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>3.3.0</version>
  <exclusions>
    <exclusion>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
    </exclusion>
  </exclusions>
</dependency>

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>${selenium.version.you.require}</version>
</dependency>

Javadocs: http://appium.github.io/java-client/

###Structure###

There is an abstract AppiumDriver class which inherits from the Selenium Java Client. The AppiumDriver class contains all methods shared by iOS and Android. IOSDriver and AndroidDriver both extend AppiumDriver and provide more methods, and specific implementations for some methods.

In the same way, IOSElement and AndroidElement both are subclasses of MobileElement

You can instantiate and AppiumDriver with the class of element you want commands to return. For example AppiumDriver<MobileElement> driver; and now when you call the Find functions, they return elements of class MobileElement. You can also instantiate drivers like this, to make things simpler: AndroidDriver<AndroidElement> driver = new AndroidDriver(....... IOSElement el = driver.findElementByAccessiblityId('sample');

###Added functions### More can be found in the docs, but here's a quick list of features which this project has added to the usual selenium binding.

  • startActivity()
  • resetApp()
  • getAppStringMap()
  • pressKeyCode()
  • longPressKeyCode()
  • longPressKey()
  • currentActivity()
  • getDeviceTime()
  • pullFile()
  • pushFile()
  • pullFolder()
  • replaceValue()
  • hideKeyboard()
  • runAppInBackground()
  • performTouchAction()
  • performMultiTouchAction()
  • tap()
  • swipe()
  • pinch()
  • zoom()
  • getNamedTextField()
  • isAppInstalled()
  • installApp()
  • removeApp()
  • launchApp()
  • closeApp()
  • endTestCoverage()
  • isLocked()
  • shake()
  • scrollTo()
  • scrollToExact()
  • openNotifications()
  • Context Switching: .context(), .getContextHandles(), getContext())
  • getNetworkConnection(), setNetworkConnection()
  • ignoreUnimportantViews(), getSettings()
  • toggleLocationServices()
  • lockDevice()
  • unlockDevice()

Locators:

  • findElementByAccessibilityId()
  • findElementsByAccessibilityId()
  • findElementByIosUIAutomation()
  • findElementsByIosUIAutomation()
  • findElementByAndroidUIAutomator()
  • findElementsByAndroidUIAutomator()

Note to developers!

If you are working on this project and use Intellij Idea, you need to change the compiler to the Eclipse compilers instead of the default. If you are using the Eclipse IDE, make sure you are using version Luna or later.

##Changelog## 3.4.0 (still not released)

  • Update to Selenium v2.52.0
  • getAppStrings() methods are deprecated now. They are going to be removed. getAppStringMap() methods were added and now return a map with app strings (keys and values) instead of a string. Thanks to @rgonalo for the contribution.
  • Add getAppStringMap(String language, String stringFile) method to allow searching app strings in the specified file
  • FIXED of the bug which causes deadlocks of AppiumDriver LocalService in multithreading. Thanks to saikrishna321 for the bug report.
  • FIXED Zoom methods, thanks to @kkhaidukov
  • FIXED The issue of compatibility of AppiumServiceBuilder with Appium node server v >= 1.5.x. Take a look at #305
  • getDeviceTime() was added. Thanks to @SrinivasanTarget for the contribution.
  • FIXED longPressKeyCode() methods. Now they use the convenient JSONWP command.Thanks to @kirillbilchenko for the proposed fix.
  • FIXED javadoc.
  • Page object tools were updated. Details read here: #311, #313, #317. By.name locator strategy is deprecated for Android and iOS. It is still valid for the Selendroid mode. Thanks to @SrinivasanTarget for the helping.
  • The method lockScreen(seconds) is deprecated and it is going to be removed in the next release. Since Appium node server v1.5.x it is recommended to use AndroidDriver.lockDevice()...AndroidDriver.unlockDevice() or IOSDriver.lockDevice(int seconds) instead. Thanks to @namannigam for the catching. Read #315
  • maven-release-plugin was added to POM.XML configuration
  • #320 fix. The Widget.getSelfReference() was added. This method allows to extract a real widget-object from inside a proxy at some extraordinary situations. Read: PR. Thanks to SergeyErmakovMercDev fpr the reporting.

3.3.0

  • updated the dependency on Selenium to version 2.48.2
  • bug fix and enhancements of io.appium.java_client.service.local.AppiumDriverLocalService
    • FIXED bug which was found and reproduced with Eclipse for Mac OS X. Please read about details here: #252 Thanks to saikrishna321 for the bug report
    • FIXED bug which was found out by Jonahss. Thanks for the reporting. Details: #272 and #273
    • For starting an appium server using localService, added additional environment variable to specify the location of Node.js binary: NODE_BINARY_PATH
    • The ability to set additional output streams was provided
  • The additional startActivity() method was added to AndroidDriver. It allows to start activities without the stopping of a target app Thanks to deadmoto for the contribution
  • The additional extension of the Page Object design pattern was designed. Please read about details here: #267
  • New public constructors to AndroidDriver/IOSDriver that allow passing a custom HttpClient.Factory Details: #276 thanks to baechul

3.2.0

  • updated the dependency on Selenium to version 2.47.1
  • the new dependency on commons-validator v1.4.1
  • the ability to start programmatically/silently an Appium node server is provided now. Details please read at #240. Historical reference: The similar solution has been designed by @Hassan-Radi. The mentioned framework and the current solution use different approaches.
  • Throwing declarations were added to some searching methods. The "getMouse" method of RemoteWebDriver was marked Deprecated
  • Add replaceValue method for elements.
  • Replace sendKeyEvent() method in android with pressKeyCode(int key) and added: pressKeyCode(int key, Integer metastate), longPressKeyCode(int key), longPressKeyCode(int key, Integer metastate)

3.1.1

  • Page-object findBy strategies are now aware of which driver (iOS or Android) you are using. For more details see the Pull Request: appium#213
  • If somebody desires to use their own Webdriver implementation then it has to implement HasCapabilities.
  • Added a new annotation: WithTimeout. This annotation allows one to specify a specific timeout for finding an element which overrides the drivers default timeout. For more info see: appium#210
  • Corrected an uninformative Exception message.

3.0.0

  • AppiumDriver class is now a Generic. This allows us to return elements of class MobileElement (and its subclasses) instead of always returning WebElements and requiring users to cast to MobileElement. See appium#182
  • Full set of Android KeyEvents added.
  • Selenium client version updated to 2.46
  • PageObject enhancements
  • Junit dependency removed

2.2.0

  • Added new TouchAction methods for LongPress, on an element, at x,y coordinates, or at an offset from within an element
  • SwipeElementDirection changed. Read the documentation, it's now smarter about how/where to swipe
  • Added APPIUM_VERSION MobileCapabilityType
  • sendKeyEvent() moved from AppiumDriver to AndroidDriver
  • linkText and partialLinkText locators added
  • setValue() moved from MobileElement to iOSElement
  • Fixed Selendroid PageAnnotations

2.1.0

  • Moved hasAppString() from AndroidDriver to AppiumDriver
  • Fixes to PageFactory
  • Added @AndroidFindAll and @iOSFindAll
  • Added toggleLocationServices() to AndroidDriver
  • Added touchAction methods to MobileElement, so now you can do element.pinch(), element.zoom(), etc.
  • Added the ability to choose a direction to swipe over an element. Use the SwipeElementDirection enums: UP, DOWN, LEFT, RIGHT

2.0.0

  • AppiumDriver is now an abstract class, use IOSDriver and AndroidDriver which both extend it. You no longer need to include the PLATFORM_NAME desired capability since it's automatic for each class. Thanks to @TikhomirovSergey for all their work
  • ScrollTo() and ScrollToExact() methods reimplemented
  • Zoom() and Pinch() are now a little smarter and less likely to fail if you element is near the edge of the screen. Congratulate @BJap on their first PR!

1.7.0

  • Removed scrollTo() and scrollToExact() methods because they relied on complexFind(). They will be added back in the next version!
  • Removed complexFind()
  • Added startActivity() method
  • Added isLocked() method
  • Added getSettings() and ignoreUnimportantViews() methods

1.6.2

  • Added MobilePlatform interface (Android, IOS, FirefoxOS)
  • Added MobileBrowserType interface (Safari, Browser, Chromium, Chrome)
  • Added MobileCapabilityType.APP_WAIT_ACTIVITY
  • Fixed small Integer cast issue (in Eclipse it won't compile)
  • Set -source and -target of the Java Compiler to 1.7 (for maven compiler plugin)
  • Fixed bug in Page Factory

1.6.1

  • Fixed the logic for checking connection status on NetworkConnectionSetting objects

1.6.0

  • Added @findBy annotations. Explanation here: appium#68 Thanks to TikhomirovSergey
  • Appium Driver now implements LocationContext interface, so setLocation() works for setting GPS coordinates

1.5.0

  • Added MobileCapabilityType enums for desired capabilities
  • findElement and findElements return MobileElement objects (still need to be casted, but no longer instantiated)
  • new appium v1.2 hideKeyboard() strategies added
  • getNetworkConnection() and setNetworkConnection() commands added

1.4.0

  • Added openNotifications() method, to open the notifications shade on Android
  • Added pullFolder() method, to pull an entire folder as a zip archive from a device/simulator
  • Upgraded Selenium dependency to 2.42.2

1.3.0

  • MultiGesture with a single TouchAction fixed for Android
  • Now depends upon Selenium java client 2.42.1
  • Cleanup of Errorcode handling, due to merging a change into Selenium

1.2.1

  • fix dependency issue

1.2.0

  • complexFind() now returns MobileElement objects
  • added scrollTo() and scrollToExact() methods for use with complexFind()

1.1.0

  • AppiumDriver now implements Rotatable. rotate() and getOrientation() methods added
  • when no appium server is running, the proper error is thrown, instead of a NullPointerException

1.0.2

  • recompiled to include some missing methods such as shake() and complexFind()

Running tests

Run a test using

mvn -Dtest=io.appium.java_client.MobileDriverAndroidTest clean test

About

Java language binding for writing Appium Tests, conforms to Mobile JSON Wire Protocol

License:Apache License 2.0


Languages

Language:HTML 58.8%Language:Java 41.2%Language:Shell 0.0%Language:JavaScript 0.0%