1
파이썬 3.4에서 다음 파이썬 코드를 실행하면body = 'cmd ='+ urllib_parse.quote_plus (unicode (verb) .encode ('utf-8'))는 "name '유니 코드가 정의되지 않음을 반환합니다.
# -*- coding: utf-8 -*-
import unittest, time, re
from selenium.selenium import selenium
class google(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", 4444, "*chrome", "https://www.google.com/")
self.selenium.start()
def test_google(self):
sel = self.selenium
sel.open("/?gws_rd=ssl")
sel.type("id=gbqfq", "")
sel.type("id=gbqfq", "test")
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
나는 오류 name 'unicode' is not defined:
======================================================================
ERROR: test_google (__main__.google)
----------------------------------------------------------------------
Traceback (most recent call last):
File "google.py", line 11, in setUp
self.selenium.start()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/selenium-2.43.0-py3.4.egg/selenium/selenium.py", line 201, in start
result = self.get_string("getNewBrowserSession", start_args)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/selenium-2.43.0-py3.4.egg/selenium/selenium.py", line 236, in get_string
result = self.do_command(verb, args)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/selenium-2.43.0-py3.4.egg/selenium/selenium.py", line 215, in do_command
body = 'cmd=' + urllib_parse.quote_plus(unicode(verb).encode('utf-8'))
NameError: name 'unicode' is not defined
----------------------------------------------------------------------
어떤 문제가 있나요? 해결 방법이 있습니까?
감사합니다. Karl에게 감사드립니다. Selenium 2.43과 Python3.4 바인딩. Selenium 3.0은 꽤 새로운 기능입니다. 어떻게 Selenium3.0 유니 코드 대신 유니 코드 문자열을 사용합니까? 2.x를 제거하고 3.0을 설치하는 방법에 대해 의사가 이야기하고 있습니까? – Frank