工做機上安裝了ActivePython 2.6,一直用來編寫測試腳本。一次安裝了WebDriver 2.13的代碼後,運行了啓動FireFox來進行Web自動化測試,卻拋出了下面的異常,
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) python
結果打出來時這樣的,
TK_LIBRARY --- C:\Python26\tcl\tk8.5 --- <type 'unicode'>
TCL_LIBRARY --- C:\Python26\tcl\tcl8.5 --- <type 'unicode'> web
很奇怪,因此的環境變量的值的類型都是string,惟獨TK_LIBRARY和TCL_LIBRARY。後來再網上google了一下,原來這是python的一個bug,這裏給出一個連接http://bugs.python.org/issue6906。 測試
能夠選擇升級python,也本身手動地去打patch。diff文件地址是http://bugs.python.org/file15335/FixTk.diff。 google