ios - Is it possible to testing uitest (XCUI) when open url external browser?
问题描述
Currently, I have to create automation ui test with XCUI and I have some action to open external browser by default is Safari.
I need to create some uitest's behavior like this.
- Go to external browser when click my button.
- Check is open correct url in browser (or just open browser) ?
- Go back to our app with resume state.
Is it impossible to do that ?.
解决方案
Absolutely. Safari is an XCUIApplication just like any other with a bundle identifier of com.apple.mobilesafari
.
To check the URL you'll tap()
the URL
field (it's a button when a page loads) and read the value of the URL
field (at this point it's a textField). Once you're done asserting that, activate()
your app and you'll be back in it (note: my tests finish after asserting so I don't have to do this, but it's the published method - you could always enter debug and find how to tap the button to return to your application in the top-left of the screen if this doesn't work).
I'm happy to provide exact code if you show me you've tried this and can't get it working, but it's pretty straightforward XCUI automation.
推荐阅读
- java - 如何在 mongock 中禁用 throwExceptionIfCannotObtainLock
- reactjs - 用玩笑和酶测试按钮点击的特定功能
- java - 仅使用注释使用不同的测试数据运行测试方法多次
- php - 主题文件包含在 .ics 下载文件中
- powerbi - 如何动态/通过 API 让用户访问 power-bi 服务中的报告?
- c# - 今天如何在.net中设置输入类型日期默认值
- javascript - 为什么在使用扩展运算符设置状态时出现错误 X 不可迭代?
- c# - elasticsearch中的土耳其字符问题
- hdf - 如何制作 HDF-3.4.1.1-centos7-rpm.tar.gz 文件?
- c# - 如何将元素添加到其他方法的列表