简体   繁体   English

如何使用Python绑定在Selenium Webdriver中使用Safari浏览器

[英]How to use Safari Browser in Selenium Webdriver using Python bindings

I am not able to launch safari browser from Selenium web driver. 我无法从Selenium网络驱动程序启动safari浏览器。 I am using Python bindings. 我正在使用Python绑定。 Could not find any reference that provided detailed steps for Python. 找不到任何提供Python详细步骤的参考资料。 I am aware there is a related question on stackoverflow, but it doesn't answer for python - python selenium webdriver safari driver 我知道stackoverflow上有一个相关的问题,但它没有回答python - python selenium webdriver safari驱动程序

Followed the Documentation on http://code.google.com/p/selenium/wiki/SafariDriver , downloaded and installed safari developer certificate. 按照http://code.google.com/p/selenium/wiki/SafariDriver上的文档,下载并安装了safari开发人员证书。 This doc has code for Java and not for python bindings. 这个doc有Java代码,而不是python绑定代码。

Below is my code(I am using desired capabilities) Not sure what am I missing here - 下面是我的代码(我正在使用所需的功能)不确定我在这里缺少什么 -

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium import webdriver

browser = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.SAFARI)
browser.get('http://www.google.com')
browser.close()

From the looks of it, you're trying to open a webpage with a webbrowser. 从它的外观来看,你正试图用webbrowser打开一个网页。 Why not use "webbrowser"? 为什么不使用“webbrowser”? It's easy to get the webbrowser have safari as default: Web浏览器很容易将safari作为默认值:

import webbrowser
browser = webbrowser.get('safari')
browser.open("http://www.google.com/")

As I can't selenium set up, I'm not sure if this is what you want. 由于我不能设置硒,我不确定这是否是你想要的。 Who knows, it could be an alternative? 谁知道,它可能是另一种选择?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Selenium 2-WebDriver 的 Python 绑定最大化浏览器窗口? - How to maximize a browser window using the Python bindings for Selenium 2-WebDriver? 如何使用 Python 绑定在 Selenium webdriver 中加载 HtmlUnit 驱动程序? - How to load HtmlUnit driver in Selenium webdriver using Python bindings? 如何使用 Selenium Safari Webdriver - How to use Selenium Safari Webdriver Selenium WebDriver python绑定 - Selenium WebDriver python bindings 如何使用Selenium WebDriver + python获取浏览器控制台错误消息 - How to get browser console error messages using Selenium WebDriver + python 如何使用 selenium webdriver 和 python 关闭 chrome 浏览器弹出对话框 - how to close chrome browser popup dialog using selenium webdriver and python 如何使用Selenium WebDriver和python打开功能齐全的Chrome浏览器? - How to open a fully functioning chrome browser using selenium WebDriver with python? 如何使用python的Selenium WebDriver在浏览器上打开一个新的window? - How to open a new window on a browser using Selenium WebDriver for python? 使用 Python 绑定,Selenium WebDriver click() 有时无法正常工作。 - Using Python bindings, Selenium WebDriver click() is not working sometimes. 如何使用python绑定在Selenium WebDriver中使用数据驱动框架? - How to do data driven frame work in Selenium WebDriver using python bindings?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM