简体   繁体   English

用于Firefox的Python Selenium Webdriver无法一致打开

[英]Python selenium webdriver for firefox not opening consistantly

I am using the following python script to open and start Firefox browser. 我正在使用以下python脚本打开和启动Firefox浏览器。 It works at times while in other cases,it is giving an error.What am i doing wrong here? 有时它会工作,而在其他情况下却出现错误。我在这里做错了什么?

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()

The error i am getting is this which is not happening always. 我得到的错误是这并不总是发生。

 Traceback (most recent call last):
File "seleniumtest.py", line 4, in <module>
driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium-2.53.1-py2.7.egg\selenium\webdrier\firefox\webdriver.py", line 103, in __init__
self.binary, timeout)
File "C:\Python27\lib\site-packages\selenium-2.53.1-py2.7.egg\selenium\webdrier\firefox\extension_connection.py", line 49, in __init__
self.profile.add_extension()
File "C:\Python27\lib\site-packages\selenium-2.53.1-py2.7.egg\selenium\webdrier\firefox\firefox_profile.py", line 91, in add_extension
self._install_extension(extension)
File "C:\Python27\lib\site-packages\selenium-2.53.1-py2.7.egg\selenium\webdrier\firefox\firefox_profile.py", line 287, in _install_extension
shutil.rmtree(tmpdir)
File "C:\Python27\lib\shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "C:\Python27\lib\shutil.py", line 256, in rmtree
onerror(os.rmdir, path, sys.exc_info())
File "C:\Python27\lib\shutil.py", line 254, in rmtree
os.rmdir(path)

WindowsError: [Error 145] The directory is not empty: 'c:\\users\\cgdc\\appata\\local\\temp\\tmpqirkg6.webdriver.xpi\\components'

Check whether your file is having only read-only flag. 检查您的文件是否只有只读标志。

refer :- 参考:-

python shutil.rmtree throwing errors python shutil.rmtree抛出错误

Hope it will help you :) 希望它能对您有所帮助:)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM