我正在尝试使用安装在Macbook Air&上的Python 2.7运行Selenium Python脚本。得到ERR:
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("test-type")
driver = webdriver.Chrome(chrome_options=chrome_options)
**driver.get("https://www.google.com/");**
driver.quit()
还安装了Python 3.5但是从python3运行ERR无法找到模块: ImportError:没有名为'selenium'的模块
非常感谢任何帮助
答案 0 :(得分:0)
我终于回到了这个&我现在能够同时使用FireFox和运行macOS Sierra(10.12.1)的MacBook Air上带有Selenium 3的Chrome。我使用FF 50.1.0,Selenium 3,& Python 2.7.10或Python 3.5.2
# -*- coding: utf-8 -*-
#/usr/local/bin/geckodriver (in PATH)
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/Volumes/Untitled/Applications/Firefox.app/Contents/MacOS/firefox'
browser = webdriver.Firefox(capabilities=firefox_capabilities)
browser.get("https://www.google.com")
browser.quit()