I write Appium UI tests for my iOS app. Some of the tests have such workflow:
an app is sent to background
the user does "force touch" on the app's icon, until menu (shortcuts) appear
an app is launched from this shortcut
My environment:
Simulator iOS 13.2
appium 1.15.0
Appium Python Client 0.47
I've tried such code (Python), it doesn't do "force touch":
self.driver.background_app(-1) # this works: sends an app to backround
args = {'duration': 5, 'x': 200, 'y': 200}
self.driver.execute_script("mobile:touchAndHold", args) # this doesn't work: force touch on Home screen
(I've tried to adjust coords, e.g. (150,200), (260,400) - no app icon was pressed).
I've tried AppleScript, but all I can do now is to activate Simulator app. :)
What I've found but it's not working:
https://saucelabs.com/blog/how-to-automate-3d-force-touch-with-appium: in this post "press" command was used with "element" = AppName, but my selenium driver says "press" requires "x", "y", not "element"
https://developers.perfectomobile.com/display/TT/Using+iOS+3D+Touch: in this post, driver.executeScript("mobile:touch:tap", parms) is used, but my driver says there's no command "mobile:touch:tap":
selenium.common.exceptions.WebDriverException: Message: Unknown mobile command 'touch:tap'. Only scroll, swipe, pinch, doubleTap, twoFingerTap, touchAndHold, tap, dragFromToForDuration, selectPickerWheelValue, alert, setPasteboard, getPasteboard, source, getContexts, installApp, isAppInstalled, removeApp, launchApp, terminateApp, queryAppState, activateApp, viewportScreenshot, startPerfRecord, stopPerfRecord, installCertificate, startLogsBroadcast, stopLogsBroadcast, batteryInfo, deviceInfo, activeAppInfo, pressButton, enrollBiometric, sendBiometricMatch, isBiometricEnrolled, clearKeychains, getPermission, siriCommand commands are supported.
I've looked at XCUITestDriver documentation/code, e.g. https://github.com/appium/appium-xcuitest-driver/blob/master/lib/commands/execute.js, and can't see any 3D-touch related stuff.
So do you know:
1. how to automate 3D-touch on app icon in iOS Simulator?
2. How to check if it's supported by XCUITest-Driver?
3. Can it be automated by smth like AppleScript?
Thanks in advance :)
If you mean like https://i.stack.imgur.com/3Fo7v.png, you can open it like below.
(Ruby code)
# Long press 'Contacts' icon with W3C actions
el = #driver.find_element :name, 'Contacts'
action_builder = #driver.action
action_builder.move_to(el)
.pointer_down(:left)
.pause(action_builder.pointer_inputs[0], 2)
.pointer_up(:left).perform
https://appium.io/docs/en/commands/interactions/actions/ is the API.
You can find Python, too.
(iOS 13 does not provide '3D touch'. The feature has been long-press style)
Related
On iOS 15 a long press on the PS Button of the DualSense controller is opening the App Library and I don't receive a callback via the valueChangedHandler function. The App library which will be opened looks like this
This is how I handle all controller inputs:
func handleController(controller: GCController) {
controller.extendedGamepad?.valueChangedHandler = { [weak self] (gamepad: GCExtendedGamepad, element: GCControllerElement) in
guard let self = self else {
return
}
// no feedback received when performing a long press on the PS button
}
Can the game library be suppressed somehow? Sony's PS Remote Play app somehow manages to suppress it, but I don't know how, nor can I find anything in Apple's official API documentation.
Edit: Seems this problem only occurs on iPads, on iPhones this problem doesn't exist. Is there some API or anything on iPads to suppress this behaviour? I assume the most majority of users don't want to open the App Library in the middle of the game.
If someone ever faces the same problem you can actually disable system gestures for the Home button.
In Swift all you have to add is this line (controller is a GCController object)
controller.physicalInputProfile.buttons[GCInputButtonHome]?.preferredSystemGestureState = .disabled
In ObjectiveC it would work like this
controller.physicalInputProfile.buttons[GCInputButtonHome].preferredSystemGestureState = GCSystemGestureStateDisabled;
Thanks to the Apple employee who helped me here
https://developer.apple.com/forums/thread/711905
Edit: on tvOS this isn't working as the PS button (menu button) of a controller always have to act as home event
https://developer.apple.com/forums/thread/715012
Trying to automate the hamburger menu in a android emulator on a pixel device. I am using Appium and automating with the android driver. I see that scrollTo() is deprecated does anyone know how to go about this?
Just use this simple command for scrolling in appium using DesiredCapabilities in JAVA.
driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"Your Text\"));");
Hope this helps
So the quick answer to this is, no there is no new way. This is to my understanding because UIAutomator2 does not allow elements that are not on the screen to be found by Appium's driver. UIAutomator2 is required for automating devices on Android version 7 and high I believe.
This means that there is no way to tell which direction the element is when it is off screen. So if anyone has a solution to this I'd be happy to hear it.
Now depending on what kind of app you are automating it is possible to fake swiping to an element if you know what direction it is in. For example if your app only scrolls up and down (like many apps) then as long as you know if the element is below or above your current position you can swipe to it. This can be done with a while loop:
while(elementNotFound) {
if(findElement(byLocator)) {
elementNotFound = !elementNotFound;
}
else {
// This is where you would swipe in the direction of where the element is
}
}
The new way of swiping is to use the TouchAction class. For example you can do:
(new TouchAction<>(driver)).press(PointOption.point(startX, position.startY)
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
.moveTo(PointOption.point(endX, endY))
.release()
.perform();
Alternatively you can use the deprecated swipeTo method with UIAutomator drive type (not UIAutomator2). Again to my understanding this will only work for devices on lower Android SDK versions.
Sorry if this doesn't give you the answer you are looking for but hopefully it at least gives you a way to find your element.
With latest Appium Java client 6.1.0, you can swipe using the following code,
new AndroidTouchAction (driver)
.press (PointOption.point (startX, startY))
.waitAction (WaitOptions.waitOptions (Duration.ofMillis (1000)))
.moveTo (PointOption.point (endX, endY))
.release ()
.perform ();
Here startX, startY, endX and endY needs to be calculated as per your needs.
OR
You can even use my open source framework Coteafs-Appium v-3.0 to swipe like,
SliderActivity slide = new SliderActivity (this.androidDevice);
slide.onElement ("Slider")
.swipe (SwipeDirection.RIGHT, SwipeStartPosition.LEFT, 75);
I use the distriqt scanner ane and it works very vell on iOS. But with the similar app on Android it crashes the app immediately (while calling Scanner.service.startScan( options ))
I got follwing from logcat:
E/QCOM PowerHAL( 313): Invalid hint ID.
E/mm-camera-intf( 313): mm_camera_open: opened, break out while loop
E/InputDispatcher( 858): channel '2da9ab5b air.myfunnyappidcovered/air.myfunnyappidcovered.AppEntry (server)' ~ Channel is unrecoverably broken and will be disposed!
E/InputDispatcher( 858): channel 'e01d279 air.myfunnyappidcovered/com.distriqt.extension.scanner.zbar.ZBarScannerActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
Any Idea? All permissions and permission-freatures are set. The AS-Code works, like the iOS-compile shows. Tested with the same result on different Android-devices.
I'm using Corona sdk, and just learnt the API media.playVideo("myfilename.mp4", true, listener).
When I open a blank file with only the code:
function showSuccess()
print( "success" )
end
media.playVideo( "hummingbird.mp4" , true, showSuccess)
The corona simulator displays nothing on screen, and the output is empty as well. On my android phone the video plays fine.
Question: Can corona simulator handle media.playVideo while i'm using a windows OS?
If not possible on Windows. How can I get around this? On bigger projects I would need the showSuccess function to print "success" in order to debug.
Thank you
Replace your last line by:
media.playVideo( "hummingbird.mp4" , true, showSuccess)
Your current line invokes the showSuccess method directly on the same line, instead of passing it as a function handle.
I have a bunch of buttons that opens the default map application and puts something in the users system clipboard. It works fine on Android tablets, but the Iphone does nothing when the button is clicked. Here is the code:
case "MapYummyYummy":
System.setClipboard( "1665 Stelton Rd Piscataway Nj 08901" )
_callURL = "geo: 40.4978922, -74.4488224";
var targetURL:URLRequest = new URLRequest(_callURL);
navigateToURL(targetURL);
break;
Does anyone know the equivalent for this that will work on Iphone devices? thanks!
Have you tried this setData method? (I have no experience with this one, but looks like a viable alternative).
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/Clipboard.html#setData()
iOS launch maps via URL reference:
http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html
Querying for a location:
http://maps.apple.com/?q=cupertino
setting a start and end for directions:
http://maps.apple.com/?daddr=San+Francisco,+CA&saddr=cupertino
Hope it works for ya (looked up not tested).