Java-client 2.1.0 released

Not a huge release, mostly a few methods added. Most notably: touch action methods for elements like:

element.tap()
element.zoom()
element.pinch()
element.swipe(direction, int)

And the swipe method gets a direction parameter:

element.swipe(SwipeElementDirection.RIGHT,1000);
element.swipe(SwipeElementDirection.LEFT,1000);
element.swipe(SwipeElementDirection.UP,1000);
element.swipe(SwipeElementDirection.DOWN,1000);

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
5 Likes

Thanks for the two annotations! :smiley:

1 Like

@jonahss is the following methods will work for ios simulator

element.tap()
element.zoom()
element.pinch()
element.swipe(direction, int)

It should work. See gesture test for iOS. Look at the elementGestureTest(). I was checking it against iOS 8.0 and I was using Appium 1.3.1.

StartActivity stop working in for java-client 2.1.0.
is it removed in 2.1.0 ?

When I use the method for swipe with new implementation I am getting an error like below , I am not sure if I am doing anything fundamentally wrong.

Application : IMDB Android Native Application
Object : com.imdb.mobile:id/search

  • Code Snippet
MobileElement element = (MobileElement)Driver.findElementById("com.imdb.mobile:id/search");
			element.swipe(SwipeElementDirection.LEFT, 1000);
  • Error Message

org.openqa.selenium.remote.RemoteWebElement cannot be cast to io.appium.java_client.MobileElement

Hi @JohnBinish!

What driver do you use? It looks like you use RemoteWebDriver or your own custom of AppiumDriver (which is abstract now) instead of AndroidDriver/IOSDriver.

1 Like

I am using Appium Driver

AppiumDriver driver = new AppiumDriver(url, capabilities) {
public MobileElement scrollToExact(String arg0) {
// TODO Auto-generated method stub
return null;
}
public MobileElement scrollTo(String arg0) {
// TODO Auto-generated method stub
return null;
}
};

@SergeyTichomirov

When I Changed My Driver From Appium Driver to Android Driver The Code Snippet Is Working Fine. However I Objective Is To Create A Driver Which Can Be Used For Android and iOS , So If I Initiate Android Driver These Methods Won’t Work For iOS Right ?

These methods should work fine for both Android and iOS. There some issues on the server-side (for example - problems with touch actions in WebView). These problems are going to be fixed in next releases.

Actually AppumDriver is abstract now and it is extended by AndroidDriver and IOSDriver because there are a lot of specific methods for each target platform. Some methods are implemented differently for Android and iOS. I think if there will be the supporting of WinMobile/FirefoxOS the number of methods like these will increase. So these classes were designed to avoid the possible problem of God Object.

As your tests you can parameterize them. There are a lot of stuff which describes how to do it.

You can declare AppiumDriver field and set here AndroidDriver/IOSDriver depending on given parameters

Thanks @SergeyTichomirov. I may have to create separate classes to handle different drivers. to give an backgroud about where I am facing issues: I am trying to create a tool agnostic keyword driven framework for mobile testing tools.For example Keywords like set to ‘set’ to set the text.These will work in Appium,Calabash and other tools also Web,Hybrid and Native for Android and iOS

:+1:

Is it all about statistics?

1 Like

Is StartActivity still not working? Didn’t make any changes, but maybe broke something by mistake.

its working , that was my fault :frowning:

On adding java client 2.1.0 to java build path, I am unable to get the below methods.
findElementByIosUIAutomation()
findElementsByIosUIAutomation()
findElementByAndroidUIAutomator()
findElementsByAndroidUIAutomator()

These methods are not implemented by AppiumDriver now. They are implemented by AndroidDriver and IOSDriver.

You can use

driver.findElement(MobileBy.IosUIAutomation(“yourlocator”))

instead of them.

1 Like

Yup got it :)…Thanks for the reply…

Hi,
I am new to appium. Currently I am using scrollTo and scrollExact method for android emulator. Both are scrolling but it is scrolling till the end.But I wnt it to scroll to specific element.
Can anyone help me on that or whether that is a bug?
I am using java-client-2.1.0.jar

Hi @Sandipan_Jana ,
You can check my comments and video on below link