python selenium webdriver safari 驱动程序

发布于 2024-11-24 01:58:46 字数 240 浏览 4 评论 0原文

快速提问,我一直在构建一个 python selenium 框架来测试我们的网站。我已经成功实现了 Firefox、Chrome 和 IE 浏览器测试。但一直在寻找Safari驱动程序。我知道在官方文档中它简要描述了它的不兼容性并且不支持 Safari。你们建议我使用 python 和 selenium 来测试 Safari 功能。使用python可以吗?

我搜索了又搜索,似乎找不到任何相关的 Safari 驱动程序。

提前致谢,

Quick question, I've been building a python selenium framework for testing our site. I have successfully implemented Firefox, Chrome and IE for browser testing. But have been searching for Safari driver. I know in the official documents it briefly describes it's incompatibilities and doesn't support Safari. What would you guys suggest I use for testing Safari functionality with python and selenium. Is it possible using python?

I've searched and search and can't seem to find any related Safari driver.

Thanks in advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

五里雾 2024-12-01 01:58:46

请查看这篇博文。这是针对 Java 的,但针对 Python 的过程应该大致相同。

Check out this blog post. It's for Java, but the process for Python ought to be much the same.

乞讨 2024-12-01 01:58:46

本地 SafariDriver 的绑定尚未实现。如果您想要此功能,请在 Selenium 的错误跟踪器中为以下问题加注星标:

The bindings for a local SafariDriver have not yet been implemented. If you want this feature, star the following issue at the bug tracker of Selenium:

痴情换悲伤 2024-12-01 01:58:46

我自己没有使用过它,但有一个 Safari 驱动程序 可以实现为向每个页面注入 javascript 的浏览器扩展。

它有一些限制,例如无法处理警报,但希望它能有所帮助。

I haven't used it myself, but there is a Safari driver available implemented as browser extension that injects javascript to each page.

It has some limitations such as not being able to handle alerts, but hopefully it helps.

可爱咩 2024-12-01 01:58:46

Safari 驱动程序是一个 Safari 扩展,您可以在 seleniumhq.org 网站的下载部分找到链接。
http://docs.seleniumhq.org/download/

您还可以从 Github 查看源代码并建造它。

Safari 的 Python Selenium 绑定并未真正实现,而是使用 java 实现。实际上,您需要 Selenium-standalone-Server jar 文件。它必须位于运行脚本的计算机上的 PATH 中。

The Safari Driver is a Safari Extension you can find a link to on the downloads section of the seleniumhq.org site.
http://docs.seleniumhq.org/download/

You can also check out the source from Github and build it.

The Python Selenium bindings for Safari are not really implemented,but use the java implementation. As a reaslt you need the Selenium-standalone-Server jar file. It must be in your PATH on the machine that runs the script.

会发光的星星闪亮亮i 2024-12-01 01:58:46

Python 支持运行 Safari 测试,您可以找到 python 示例< /a> 在此博客上的

另一个示例如何通过 selenium 网格调用 Safari 测试,请注意 selenium 网格和节点应该正在运行。

# -*- coding: utf-8 -*-
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

class PythonOrgSearch(unittest.TestCase):

def setUp(self):
    self.driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',desired_capabilities={'browserName':'safari','version':'safariversion','platform':'MAC'})

def test_search_in_python_org(self):
    driver = self.driver
    driver.get("http://www.python.org")
    self.assertIn("Python", driver.title)
    driver.maximize_window()
    elem = driver.find_element_by_name("q")
    elem.send_keys("pycon")
    elem.send_keys(Keys.RETURN)
    assert "No results found." not in driver.page_source


def tearDown(self):
    self.driver.quit()

if __name__ == "__main__":
    unittest.main()

Python support is there to run Safari tests, you can find python example on this blog

another example how to invoke Safari tests over selenium grid, please note selenium grid and node should be running.

# -*- coding: utf-8 -*-
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

class PythonOrgSearch(unittest.TestCase):

def setUp(self):
    self.driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',desired_capabilities={'browserName':'safari','version':'safariversion','platform':'MAC'})

def test_search_in_python_org(self):
    driver = self.driver
    driver.get("http://www.python.org")
    self.assertIn("Python", driver.title)
    driver.maximize_window()
    elem = driver.find_element_by_name("q")
    elem.send_keys("pycon")
    elem.send_keys(Keys.RETURN)
    assert "No results found." not in driver.page_source


def tearDown(self):
    self.driver.quit()

if __name__ == "__main__":
    unittest.main()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文