It should work. See gesture test for iOS. Look at the elementGestureTest().111 I was checking it against iOS 8.0 and I was using Appium 1.3.1.
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.
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.
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
Hi @Sandipan_Jana ,
You can check my comments and video on below link
HI, I Tried to perform a swipe with this method. I don't have error message in Appium but it doesn't work.
I use this code to initialize the driver:
import io.appium.java_client.AppiumDriver; import io.appium.java_client.ios.IOSDriver; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.Augmenter; import org.openqa.selenium.remote.DesiredCapabilities; import java.io.File; public class Application { private final static String APPIUM_PORT = "4723"; private final static String APPIUM_HOST = "127.0.0.1"; public static AppiumDriver driver; capabilities.setCapability("platformName", "iOS"); … setDriver(new IOSDriver(new URL("http://" + appiumHost + ":" + appiumPort + "/wd/hub"), capabilities)); }
... and this code to perform the swipe:
public static void testSwipe(){
MobileElement element = (MobileElement) driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAStaticText[2]"));
element.click(); // OK
element.swipe(SwipeElementDirection.LEFT, 1000); // Test Swipe #1 : KO
driver.swipe(300, 400, 10, 400, 500); // Test Swipe #2 : KO
}
Hi @okiichinpo,
I'm guessing you're talking about the first post in this thread. I believe the 1000 refers to the duration of the command in milliseconds.