Appium-Drivers-Safari(Mac/iOS)

Appium从1.20版本开始支持SafariDriver,这是一个用于桌面和移动Safari浏览器自动化测试的工具。SafariDriver是Apple二进制文件的包装器,使用W3C WebDriver协议进行通信。尽管appium-remote-debugger提供更广泛的灵活性,但SafariDriver由Apple维护,能与最新浏览器和协议保持同步。自动化Web应用仅限Safari时,SafariDriver是首选;涉及不同应用或上下文切换时,可选择XCUITestDriver或MacDriver。SafariDriver需要在macOS High Sierra或更高版本上运行,并且在iOS13及更高版本的设备上启用远程自动化。使用时需设置'automationName'为'Safari'并提供平台名称。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


Safari driver has been added to Appium since version 1.20. This driver is a wrapper over Apple’s safaridriver binary, which is included to the standard macOS distribution and implements communication with either desktop or mobile Safari browser via W3C WebDriver protocol.

Safari driver从开始添加到Appium1.20版本中
这个驱动是 Apple's safaridriver的二进制文件的包装器
包含在macOS标准发行版中并通过W3C WebDriver协议实现与桌面或移动端浏览器的通信

Development of the Safari driver happens at the appium-safari-driver repo.

Safari driver开发在appium-safari-driver repo中进行

Appium also supports mobile Safari automation and Safari web views automation using the appium-remote-debugger. This module is used to implement context switching feature with XCUITest automation name. It is more universal and flexible than the current Safari driver, however it is using the undocumented WebKit communication protocol under the hood. Which means the development of it and the effort to keep it in working state is comparably high while the list of supported features is smaller. On the other hand safaridriver is maintained by Apple, which means it is always in sync with the most recent browser and communication protocol requirements.

Appium也支持使用appium-remote-debugger调试
移动端Safari automation和Safari web views automation.
此模式是适用于具有XCUITest automation name的环境切换
它更具普遍性并且比当前Safari driver更灵活.
但它使用未经证明的WebKit秘密通信协议.
这意味着它的开发和维持工作状态所需的努力相对较高.
另外,safaridriver是由苹果公司来维护.
这一位置它始终与最新的浏览器和通信协议同步

Long story short, it makes sense to prefer this driver if it is necessary to only automate a web application that only works in Safari browser (either mobile or desktop). In case it is necessary to interact with native context or switch between different applications/contexts while automating your scenario then the obvious choice would be either XCUITest Driver (for the mobile platform) or Mac driver (for the desktop platform).

简而言之,它更喜欢这个driver假如只需在automate在web application中工作的Safari浏览器(移动或桌面)
万一有必要与本地画家交互或者在不同的应用程序/环境之间切换在实现场景自动化的同时将是XCUITest Driver(对于移动平台)或Mac driver(对于桌面平台)其中一个
Requirements and Support

In addition to Appium’s general requirements:

  • Run the safaridriver --enable command from the macOS terminal and provide your administrator password before any automated session will be executed. This only should be done once.
从MacOS终端运行`safaridriver --enable`指令
并在执行任何会话之前提供你的管理员密码,
这只需要做一次
  • In order to automate Safari on real devices it is necessary to enable Remote Automation switch in Settings → Safari → Advanced → Remote Automation for these particular devices and trust them on the target host. The device’s screen must not be locked while starting tests.
以便automate Safari在真机上实现,
它必须启用远程切换`Settings → Safari → Advanced → Remote Automation`
对于这些特殊设备并在信任到目标主机上.
这个device's屏幕在启动测试时不得被锁定
  • Only macOS (High Sierra or newer) is supported as the host platform.
仅MacOS支持主机平台(High Sierra or newer)
  • Only iOS 13 and newer is supported for mobile browser automation. As it is stated in the WebKit blog article, Safari for iOS does not allow WebDriver-initiated navigations to be handled outside of Safari. In other words, clicking a tel:// link will not offer to place a phone call, and clicking an app store link will not redirect the user to the App Store. Similarly, non-Safari content displayed by the system–such as update dialogs, app notifications, incoming calls, etc.–are suppressed while a WebDriver session is active.
移动端浏览器仅支持iOS13和新版本.
如WebKit博客中所述,
Safari不允许为iOS WebDriver-initiated导航在Safari以外的情况处理.
换句话说,点击`tel:// link`'将不会提供呼叫的机会,
并且点击一个app store link,将不会把用户添加到app store.
类似的, non-Safari也会通过系统显示
例如 update dialogs, app notifications, incoming calls, etc.在WebDriver session活动状态时被禁止
Usage

The way to start a session using the Safari driver is to include the automationName capability in your new session request, with the value Safari. Of course, you must also include appropriate platformName (Mac or iOS). Read https://github.com/appium/appium-safari-driver/blob/master/README.md for more details.

开始Safari driver的使用方式包括`automationName`功能在你的新会话请求中
值为'Safari'
当然,你必须包含适配的`platformName` (`Mac` or `iOS`)
Read https://github.com/appium/appium-safari-driver/blob/master/README.md for more details.
Capabilities

The list of available driver capabilities could be found at https://github.com/appium/appium-safari-driver/blob/master/README.md

可用的驱动功能列表可在...查询
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

古希腊掌管野猫的神-臭臭猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值