I am automating a React-native augmented reality app. We are using the Android emulator virtual camera and use Alt+WASDZ keys to navigate around.
adb shell input keyevent KEYCODE_ALT_LEFT
or adb shell sendevent /dev/input/event1 1 0057 1
Appium code:
((AndroidDriver<AndroidElement>)_driver).LongPressKeyCode(AndroidKeyCode.Keycode_ALT_LEFT, AndroidKeyMetastate.Meta_Alt_LEFT_On);
((AndroidDriver<AndroidElement>)_driver).PressKeyCode(AndroidKeyCode.Keycode_D);
None of the above commands are working. Is this supported or I am sending the commands incorrectly?
react native - Automating tests in 3d emulator’s virtual camera - Stack Overflow
Using AppleScript helped.
set x to 30
set y to 40
do shell script "
/usr/bin/python <<END
import sys
import time
from Quartz.CoreGraphics import *
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
mouseEvent(kCGEventLeftMouseDown, posx,posy);
mouseEvent(kCGEventLeftMouseUp, posx,posy);
ourEvent = CGEventCreate(None);
currentpos=CGEventGetLocation(ourEvent); # Save current mouse position
mouseclick(" & x & "," & y & ");
mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position
END"
tell application "System Events"
try
key down option
repeat 500 times
tell application "System Events"
key down "a"
end tell
end repeat
key up "a"
delay 5
repeat 500 times
tell application "System Events"
key down "d"
end tell
end repeat
key up "d"
delay 5
repeat 500 times
tell application "System Events"
key down "w"
end tell
end repeat
key up "w"
delay 5
repeat 500 times
tell application "System Events"
key down "s"
end tell
end repeat
key up "s"
delay 5
end try
key up option
end tell
If you need to press any key with ALT key depressed then the command should look like
driver.pressKey(new KeyEvent(AndroidKey.A)
// could also try KeyEventMetaModifier.ALT_ON
.withMetaModifier(KeyEventMetaModifier.ALT_LEFT_ON));
Tried this
for ( var i = 0; i < 500; i++)
{
((AndroidDriver)_driver).LongPressKeyCode(new KeyEvent(AndroidKeyCode.Keycode_D)
// could also try KeyEventMetaModifier.ALT_ON
.WithMetaKeyModifier(AndroidKeyCode.MetaAlt_ON));
}
which does not work probably since it needs raw keyboard inputs.
are you sure long press should be applied?
also the implementation might be buggy in the dotnet client. Could you also attach server logs?