Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way i can send key events to ios device #4479

Closed
naveenjammula opened this issue Feb 3, 2015 · 10 comments
Closed

Is there any way i can send key events to ios device #4479

naveenjammula opened this issue Feb 3, 2015 · 10 comments
Assignees

Comments

@naveenjammula
Copy link

I want to press the Home key in iOS by using the python script. Please let me know how to proceed

@triager triager added the Needs Triage bugs which are not yet confirmed label Feb 3, 2015
@naveenjammula naveenjammula changed the title Is there any way i send key events to ios device Is there any way i can send key events to ios device Feb 3, 2015
@amedvedjev
Copy link
Contributor

only in simulator:

Runtime runtime = Runtime.getRuntime();
String[] args = {"osascript", "-e", "tell application "System Events" \n tell application "iOS Simulator" to activate \n tell application "System Events" to keystroke "h" using {command down, shift down} \n end tell"};
runtime.exec(args);

@naveenjammula
Copy link
Author

i want to send Home key on real iOS device

@omoskovko
Copy link

I want too but as I understand there is no possibility to do it on real iOS device because of xcode limitation.

UIATarget class has only small list of methods listen below:
Device Controls and Actions
clickVolumeDown
clickVolumeUp
holdVolumeDown
holdVolumeUp
lockForDuration
lock
shake
unlock
https://developer.apple.com/library/ios/documentation/ToolsLanguages/Reference/UIATargetClassReference/index.html

@imurchie
Copy link
Contributor

imurchie commented Feb 3, 2015

Given that you cannot automate another app, why do you want to press the Home key?

@omoskovko
Copy link

With Android I can press Home button and send application to the background or start another application. I need it to test notification messages that my application send when it appear in background.

@imurchie
Copy link
Contributor

imurchie commented Feb 4, 2015

But you cannot do that in iOS. Android allows you to open multiple apps and automate them. iOS does not. Unfortunately.

@omoskovko
Copy link

It's not true. In iOS-7 you can open notification window and press calc button. After that my application go to the background and calculator we'll be in foreground. And I can receive notification message from my application. If you want to see how I do that look in code bellow.

    def start_calc(self):
        CR_Window = self.driver.find_element_by_ios_uiautomation('UIATarget.localTarget().frontMostApp().mainWindow()')
        end_y = CR_Window.size['height']
        self.driver.swipe(20, end_y, 20, 100)
        self.driver.find_element_by_name('Calculator').click()
        self.driver.find_element_by_name('Result')

    def open_notification_window(self):
        CR_Window = self.driver.find_element_by_ios_uiautomation('UIATarget.localTarget().frontMostApp().mainWindow()')
        end_y = CR_Window.size['height']
        self.driver.swipe(20, 0, 20, end_y)
        el = self.driver.find_element_by_name('All')

        uTouch = TouchAction(self.driver)
        p = uTouch.press(x=el.location['x']+2, y=el.location['y']+2)
        p.release().perform()

    def open_notification(self, user):
        uTouch = TouchAction(self.driver)

        nLine = self.driver.find_element_by_name('Zultys Mobile, now, You have incoming call from {}'.format(user.extension))
        p = uTouch.press(x=nLine.location['x']+2, y=nLine.location['y']+2)
        p.release().perform()

But unfortunately it's work only with iOS-7. In iOS-8 notification window is not visible.

@moizjv
Copy link
Member

moizjv commented May 5, 2015

Does not look like an issue. Unfortunately is a limitation by iOS

@rutin31
Copy link

rutin31 commented Sep 14, 2017

imurchie commented on 4 Feb 2015

But you cannot do that in iOS. Android allows you to open multiple apps and automate them. iOS does not. Unfortunately.

--
Has something changed in the last appium(betta 1.6.6) version for ios ?

@lock
Copy link

lock bot commented Apr 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants