iOS模拟器用于UITesting的位置
我正在尝试在持续集成服务器上运行UITests(我正在使用Bitrise)。因此,在我的一次测试中,我有以下几点:iOS模拟器用于UITesting的位置,ios,continuous-integration,xcode-ui-testing,ui-testing,bitrise,Ios,Continuous Integration,Xcode Ui Testing,Ui Testing,Bitrise,我正在尝试在持续集成服务器上运行UITests(我正在使用Bitrise)。因此,在我的一次测试中,我有以下几点: let myLocationPin = app.otherElements["My Location"] self.expectation(for: exists, evaluatedWith: myLocationPin, handler: nil) self.waitForExpectations(timeout: 20, handler: n
let myLocationPin = app.otherElements["My Location"]
self.expectation(for: exists, evaluatedWith: myLocationPin, handler: nil)
self.waitForExpectations(timeout: 20, handler: nil)
expect(myLocationPin.exists).to(beTrue())
expect(myLocationPin.isHittable).to(beTrue())
myLocationPin.tap()
它在我的本地机器上运行良好,但在CI服务器上运行测试后,它就失败了。我发现失败的原因是运行测试的模拟器没有选择任何位置。我试图添加一个GPX文件,但也没有成功。有什么建议吗 在运行之前,您是否从下拉列表中选择了本地计算机上的位置 如果是这种情况,您将无法使用图形用户界面在bitrise上执行此操作,但是可以根据方案选择位置 您可以按照此帖子设置方案的位置: 更新: 如果上述方法无法解决问题,另一种解决方案是: 要更改模拟器本身中的位置,您需要在UITest之前添加一个
脚本
步骤,包括以下脚本:
# download set-simulator-location
brew install lyft/formulae/set-simulator-location
# run simulator
export IOS_SIMULATOR_UDID=`instruments -s devices | grep "iPhone 6 (10.3) \[" | awk -F '[ ]' '{print $4}' | awk -F '[\[]' '{print $2}' | sed 's/.$//'`
echo $IOS_SIMULATOR_UDID
open -a "simulator" --args -CurrentDeviceUDID $IOS_SIMULATOR_UDID
# wait simulator to start fully
sleep 15
# set location
set-simulator-location -q London
不要忘记将iPhone 6(10.3)更改为您需要的模拟器,并将伦敦
更改为您自己的位置,使用-c
标志您还可以设置坐标
有关
设置模拟器位置的更多信息,请访问:如果您希望在模拟器中自定义位置,请选择模拟器并遵循以下两个步骤。
并更改位置谢谢您的回答。我已经尝试了建议的解决方案,但仿真器似乎不尊重所选的测试位置。显然,在使用xcodebuild
时,GPX文件不会被读取。相反,lyft解决方案似乎有效:)