简体   繁体   中英

Python selenium webdriver for firefox not opening consistantly

I am using the following python script to open and start Firefox browser. 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

Hope it will help you :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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