首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >一起运行和通信Calabash android和calabash iOS

一起运行和通信Calabash android和calabash iOS
EN

Stack Overflow用户
提问于 2016-02-01 20:23:44
回答 2查看 335关注 0票数 1

有没有人尝试过同时运行calabash-ios和calabash android?

假设我在android上安装了应用程序A,在iOS上安装了应用程序B,并希望从应用程序A发送一些消息,并在应用程序B中进行验证。

请让我知道,如果有人这样做,或任何想法如何做这将是非常有帮助的。

你好,尼尚特·辛格

EN

回答 2

Stack Overflow用户

发布于 2016-02-03 18:18:06

这个答案来自于记忆,所以如果有任何错误,我深表歉意。如果我可以得到我的旧代码,我将重新检查这一点,并在必要时更新。

注意:我的经验是使用真实设备进行此操作,因此模拟器可能会略有不同。

对于android,您可以手动配置驱动程序的多个实例。

代码语言:javascript
复制
@android_app1 = Calabash::Android::Operations::Device.new(self, 'DEVICE_SERIAL1', 123, '/path/to/app', '/path/to/testserver', 456)
@android_app2 = Calabash::Android::Operations::Device.new(self, 'DEVICE_SERIAL2', 124, '/path/to/app', '/path/to/testserver', 457)

实例化后,可以通过直接调用特定设备来运行方法

代码语言:javascript
复制
@android_app1.reinstall_apps
@android_app2.reinstall_apps

或者,您可以使用一种方法来定义哪个设备是您希望其运行的默认设备。那么任何calabash命令都将在该设备上运行。此设置仅适用于安卓系统,不会以任何方式影响iOS设备。

代码语言:javascript
复制
Calabash::Android::Operations.set_default_device(@android_app2)
query("* text:'thing'") # Will be run on @android_app2
Calabash::Android::Operations.set_default_device(@android_app1)
query("* text:'some_other_thing'") # Will be run on @android_app1

根据我对iOS的记忆,您可以使用与只使用一个iOS设备的情况相同的方式来设置iOS驱动程序,即设置环境变量。要使用iOS设备,您需要确保有一个环境变量的设置,我认为它是DEVICE_ENDPOINT。如果使用iOS设备的ip设置此环境变量,则来自iOS的所有命令都将发送到calabash设备。如果它被设置为空字符串,那么任何calabash命令都将被发送到android设备。

因此,假设您已经正确配置了iOS环境变量,并且您有一个包含iOS设备IP的常量IPHONE_IP。

代码语言:javascript
复制
# Start app on iOS device. Assuming you have set your env vars as per the docs.
@calabash_launcher = Calabash::Cucumber::Launcher.new
@calabash_launcher.relaunch
@calabash_launcher.calabash_notify(self)

ENV['DEVICE_ENDPOINT'] = '' # Clear this env var so that android is targeted

@android_app1 = Calabash::Android::Operations::Device.new(self, 'DEVICE_SERIAL1', 123, '/path/to/app', '/path/to/testserver', 456)
@android_app2 = Calabash::Android::Operations::Device.new(self, 'DEVICE_SERIAL2', 124, '/path/to/app', '/path/to/testserver', 457)

# Do some stuff declaring which device to act on each time.
@android_app1.reinstall_apps # Runs on @android_app1
@android_app2.reinstall_apps # Runs on @android_app2

# Do some stuff by defining which device you want to be used
Calabash::Android::Operations.set_default_device(@android_app2)
query("* text:'thing'") # Will be run on @android_app2
Calabash::Android::Operations.set_default_device(@android_app1)
query("* text:'some_other_thing'") # Will be run on @android_app1

# Now to use the iOS device
ENV['DEVICE_ENDPOINT'] = IPHONE_IP # Set so that calabash knows to use iOS device
query("* text:'thing'") # Will be run on iOS device

ENV['DEVICE_ENDPOINT'] = ''
query("* text:'thing'") # Will be run on @android_app1 as it is still set to be the default android device

我最终创建了一个为我处理这些东西的类,因为添加和删除env var以及在设备之间切换变得很烦人。我也最终放弃了复杂的跨平台多设备实现,转而使用模拟。希望这对你有用!

票数 0
EN

Stack Overflow用户

发布于 2016-02-03 23:25:27

我想说这与calabash没有任何关系,因为这两个进程需要一种同步数据的方法,因此您可能想要尝试这样的Is communication between two ruby processes possible/easy?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35130469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档