问题
We have this scenario:
Execute the script in app1, in certain step app1 sends us a SMS with a URL, app1 is expecting a validation code in a textfield
We have to open SMS app to verify if SMS exists, this SMS has a URL and when we click on it, it sends us to app1 again but automatically the validation code is written in the textfield.
then, continue with the script.
is it possible to do this? what do we need to make it?
Thanks.
回答1:
Yes, As per your scenario you have to launch the messages(call it as app2) application in the middle of execution of script in app1. You can open the app2 by using below code.
driver.startActivity(app2PackageName, app2ActivityName);
Now app2 will be opened you can click on the link in app2 which will open app1 and you can access the elements in app1.
回答2:
According to this article, it's possible if you're using Appium's XCUITest driver.
Please note it only supports iOS versions 9.3 and above.
You can find a few other application management commands that might interest you at the official docs.
回答3:
For iOS you can bring up the SMS app and do whatever you like within the app. For example, you could open SMS app, then open the latest message and then click (or copy) the link.
I use ruby. I use methods based on XCUITest driver (that Noyo linked already) Methods that can be used are the following:
Method for launching any app installed on device:
def launch_system_app(bundle_id)
@driver.execute_script('mobile: launchApp',
{'bundleId': "#{bundle_id}"}
);
end
Method for terminating the launched app:
def terminate_system_app(bundle_id)
@driver.execute_script('mobile: terminateApp',
{'bundleId': "#{bundle_id}"}
);
end
Method for copying given string to iOS device clipboard:
def set_pasteboard(content)
@driver.set_clipboard(content: content)
end
Call using Messages app bundle id:
launch_system_app("com.apple.MobileSMS")
terminate_system_app("com.apple.MobileSMS")
来源:https://stackoverflow.com/questions/43126999/is-it-possible-to-automate-two-apps-at-the-same-time-in-ios