我曾经在 Python 中有一个运行良好的 firefox 网站的 selenium 脚本代码。过了一段时间我更新了 Firefox(48)和 selenium 2.9.1.1,python 是 3.5.0
编码,
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re, os
class Jqueryx(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://127.0.0.1:8080/"
self.verificationErrors = []
self.accept_next_alert = True
self.path_upload_quest = r'C:\\Users\jl\Documents\DONNEES\DONNEES_LIMONDE'
self.path_upload_ref = r'C:\\Users\jl\Documents\DONNEES\DONNEES_LIMONDE\ref'
def test_jqueryx(self):
driver = self.driver
driver.get(self.base_url + "/lim/home.php")
如果我现在运行脚本,我会收到以下消息:
os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' >executable 需要在 PATH 中。
所以我下载了这个 geckodriver 东西并尝试将它添加到 python 但还没有任何效果,
我尝试在脚本中添加它;
os.environ["PATH"] += r'C:\Users\jl\geckodriver'
没有成功或在 site-package 文件夹中添加 .pth 文件,但也没有改变......
我该怎么做才能让这个脚本重回正轨?
谢谢