Selenium:Python webdriver和Firefox Profiles

时间:2011-10-28 12:09:14

标签: python selenium webdriver

我运行Python测试但是我收到此错误

C:\selenium>E[Error 32] unable to access this file. This file is used by another process: 'c:\\docume~1\\ammini~1\\impost~1\\temp\\tmpfhvfvf\\cert8.db'

======================================================================
ERROR: test_w (__main__.W)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\selenium\w.py", line 15, in test_w
    driver.get("/")
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 165, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 153, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py"
, line 116, in check_response
    zeroeth = value['stackTrace'][0]
IndexError: list index out of range

----------------------------------------------------------------------
Ran 1 test in 6.969s

FAILED (errors=1)

这里是从Selenium IDE生成的完整代码....

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re

class W(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(1)
        self.base_url = "http://www.google.it/"
        self.verificationErrors = []

    def test_w(self):
        driver = self.driver
        driver.get("/")
        driver.find_element_by_id("lst-ib").click()
        driver.find_element_by_id("lst-ib").clear()
        driver.find_element_by_id("lst-ib").send_keys("pippo")
        driver.find_element_by_id("lst-ib").clear()
        driver.find_element_by_id("lst-ib").send_keys("outlet")
        driver.find_element_by_link_text("store").click()

    def is_element_present(self, how, what):
        try: self.driver.find_element(by=how, value=what)
        except NoSuchElementException, e: return False
        return True

    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)

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

如果我创建另一个Firefox配置文件,我该如何使用它? 我还需要其他Firefox配置文件吗?我创建了另一个配置文件,并将其放在w.py(C:\ selenium)的Python测试的同一目录中,但它不起作用...

非常感谢。

最诚挚的问候。

G:

0 个答案:

没有答案