Post not yet marked as solved
I see that apple provides dynamic flags here: https://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-34.1.1/IOHIDSystem/IOKit/hidsystem/IOHIDUsageTables.h.auto.html
In page (0x07).
I can send a HID using appium for now, using this command in python:
self.driver.execute_script("mobile: performIoHidEvent", {"page": 0x07, "usage": 0xE0, "durationSeconds": 0.5})
But I cannot send dynamic flags to do a CMD.+ Combinations or shift + combinations.
I would like know if there is any other way I can do multi-key operations such as CMD + A, CMD + C etc.
Post not yet marked as solved
As far as I understand the typeText Function simply copies the value from Test script to the textbox. Is there a function that actually types ( Keyboard input ) to a textbox?
I have been through multiple Apple Dev forums and Stack-overflow but was not able to find an answer, could you please guide me on the same?
Post not yet marked as solved
In MacOS I can achieve this via
func sendKeyStrike(_ keyCode: CGKeyCode, useCommandFlag: Bool) {
let sourceRef = CGEventSource(stateID: .combinedSessionState)
if sourceRef == nil {
NSLog("FakeKey: No event source")
return
}
let keyDownEvent = CGEvent(keyboardEventSource: sourceRef,
virtualKey: keyCode,
keyDown: true)
if useCommandFlag {
keyDownEvent?.flags = .maskCommand
}
let keyUpEvent = CGEvent(keyboardEventSource: sourceRef,
virtualKey: keyCode,
keyDown: false)
keyDownEvent?.post(tap: .cghidEventTap)
keyUpEvent?.post(tap: .cghidEventTap)
}
Is there a function call either in XCUITest or any other framework to achieve keyboard strokes in IOS?
IOS Seems to have HID keycodes but I just can't find a way to send them to the device. Either through XCUITest or any other framework. (I am ok with simulating a HID device using python or something else to command my iOS device as well.
Post not yet marked as solved
I am trying to change the Mac OS Apps to a new locale other than English using the following arguments in XCUITest:
app.launchArguments = [
"-inUITest",
"-AppleLanguages",
"(nl)",
"-AppleLocale",
"nl_NL"
]
But I get the following message on the console:
Launching macOS application via NSWorkspace while sandboxed. Launch arguments and environment variables may be dropped
The app loads in English itself.
Is there any other way I can change the language of such apps ?
I DONT mind changing the system language as well, but it needs to be done programatically. I tried writing a zsh script to do sudo languagesetup but it requires a restart for the system language to change, which I can't do when my automation is running. If there is any other way please let me know.
EDIT: I open a third party app using the bundle Identifier, like this:
XCUIApplication(bundleIdentifier: "<app-bundle-name>")
Post not yet marked as solved
Does the XCUITest typetext function actually send a keyboard event through the iOS keyboard or does it simple copy the value provided to it directly into the text box?
I tried to send in Chinese through the typeText Function while the keyboard was of English type, the text box was populated correctly with Chinese characters. But this according to me shows that the typeText function just copies the text given to it to the text box and does not send a keyboard event.
Is my understanding correct?