Traceback (most recent call last):
File "D:\workspace\boss_autotest\lib\basictestcase.py", line 77, in run
self.preTest()
File "D:\workspace\boss_autotest\tc\add_kfaccount.py", line 33, in preTest
self.browser=browserinstance.setbrowser('firefox',self.url)
File "D:\workspace\boss_autotest\tc\initbrowser.py", line 36, in setbrowser
self.browser = webdriver.Firefox()
File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 51, in __init__
self.binary, timeout),
File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 43, in launch_browser
self._start_from_profile_path(self.profile.path)
File "C:\Python26\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 65, in _start_from_profile_path
env=self._firefox_env).communicate()
File "C:\Python26\lib\subprocess.py", line 633, in __init__
errread, errwrite)
File "C:\Python26\lib\subprocess.py", line 842, in _execute_child
startupinfo)
TypeError: environment can only contain strings
这个TypeError,大概的意思就是当前environment环境变量environment,含有value值类型非string的key。于是在subprocess.py,加入下面的代码,
import types
for k, v in env.iteritems():
if type(v) is not types.StringType: print k, v, type(v)
结果打出来时这样的,
TK_LIBRARY --- C:\Python26\tcl\tk8.5 --- <type 'unicode'>
TCL_LIBRARY --- C:\Python26\tcl\tcl8.5 --- <type 'unicode'>
很奇怪,所以的环境变量的值的类型都是string,唯独TK_LIBRARY和TCL_LIBRARY。后来再网上google了一下,原来这是python的一个bug,这里给出一个链接http://bugs.python.org/issue6906。
可以选择升级python,也自己手动地去打patch。diff文件地址是http://bugs.python.org/file15335/FixTk.diff。