If you see your methods are not the same as mine, so yes, you are using deprecated methods, although they still work.
About opening Control Center in iOS. On some iPhones I’m not able to, dont know why, but although the swipe is performed, the control panel doesn’t open. But it depends on the iPhone and iOS you are using.
Just tested with iPhone5S - iOS11.2.5 and this works:
ElementOption eoption;
eoption = new ElementOption().withElement(elmUserName);
TouchActions act = new TouchActions(driver);
act.longPress((WebElement) LongPressOptions.longPressOptions().withElement(eoption)).build().perform();
**I am getting below error message
Mar 27, 2018 12:52:57 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread “main” java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
at org.openqa.selenium.interactions.touch.TouchActions.(TouchActions.java:38)
at scripts.TouchActionExample.main(TouchActionExample.java:39)
I am using Java Client 6.0.0. Beta 4 and Selenium-Standalone-server 3.11 jars.
I have a class called Utils were I defined some useful methods, and I have a construction which is passing me the driver( sorry still at the beginning of appium and java and I might get it wrong).
Here is my code:
package resources;
import static io.appium.java_client.touch.TapOptions.tapOptions;
import static io.appium.java_client.touch.WaitOptions.waitOptions;
import static io.appium.java_client.touch.offset.ElementOption.element;
import static io.appium.java_client.touch.offset.PointOption.point;
import static java.time.Duration.ofSeconds;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
public class Utils {
public static AndroidDriver<AndroidElement> driver;
public Utils(AndroidDriver<AndroidElement> driver) {
Utils.driver = driver;
}
public void swipe(int x_start, int y_start, int x_stop, int y_stop, int duration) {
new TouchAction(driver).press(point(x_start, y_start)) .waitAction(waitOptions(ofSeconds(duration)))
.moveTo(point(x_stop, y_stop)) .release() .perform();
}
Try to update the appium server to 1.8.1
should work
for me is working:
public void tap(MobileElement el) {
new TouchAction((AndroidDriver) driver).tap(tapOptions().withElement(element(el))).perform();
}
What java client do you have?
Make sure you have 6.0.0 or 6.1.0 the stable releases. And check the above examples
I spend like one week until i made it work. I still have the warning but I can like with it.
check this out also
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(“deviceName”, “emulator-5554”);
dc.setCapability(“BROWSER_NAME”, “android”);
dc.setCapability(“platformName”, “Android”);
dc.setCapability(“appPackage”, “com.poshmark.app”);
dc.setCapability(“appActivity”, “com.poshmark.ui.MainActivity”);
try {
driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), dc);
wait = new WebDriverWait(driver, 10);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
io.appium.java_client.TouchAction action = new TouchAction((MobileDriver)driver);
action.press(PointOption.point(startx, starty)).moveTo(PointOption.point(startx, endy)).release().perform();
I tried this code, but error occured
Exception in thread “AWT-EventQueue-0” java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebDriver cannot be cast to io.appium.java_client.MobileDriver
at com.appium.example.FirstAppiumTest.scrollDown(FirstAppiumTest.java:194)
at com.appium.example.FirstAppiumTest.GatherName(FirstAppiumTest.java:206)
at com.appium.example.FirstAppiumTest.actionPerformed(FirstAppiumTest.java:176)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Why do you have this capability:
dc.setCapability(“BROWSER_NAME”, “android”);?
deviceName, platformName, platformVersion would be suitable.
And try to use my example provided above