所以我试图调试我们用ipdb运行django / phantomjs / selenium-webdrive的测试,但是交互式调试器输入太慢了,我需要按住一个键3-5秒才能记下该字符
所以我追踪它并发现它是在发起phantomJS之后发生的
class IntegrationTest(StaticLiveServerTestCase):
serialized_rollback = False
@classmethod
def setUpClass(cls):
# this will be executed at the start of IntegrationTest
super(IntegrationTest, cls).setUpClass()
import ipdb; ipdb.set_trace()
cls.driver = webdriver.PhantomJS("node_modules/phantomjs-prebuilt/bin/phantomjs") # input speed = normal
cls.driver.set_window_size(1440, 900) # input speed = need to hold key 3-5 seconds
cls.commonOp = commonOp(cls.driver, cls.live_server_url + settings.STATIC_URL + 'index.html')
cls.customDriver = customDriver(cls.driver)
@classmethod
def tearDownClass(cls):
# this will be executed at the end of IntegrationTest
> /project/bx/integration_test/tests.py(20)setUpClass()
18 super(IntegrationTest, cls).setUpClass()
19 import ipdb; ipdb.set_trace()
---> 20 cls.driver = webdriver.PhantomJS("node_modules/phantomjs-prebuilt/bin/phantomjs")
21 cls.driver.set_window_size(1440, 900)
22 cls.commonOp = commonOp(cls.driver, cls.live_server_url + settings.STATIC_URL + 'index.html')
ipdb> n <- INPUT SPEED = NORMAL
> /project/bx/integration_test/tests.py(21)setUpClass()
19 import ipdb; ipdb.set_trace()
20 cls.driver = webdriver.PhantomJS("node_modules/phantomjs-prebuilt/bin/phantomjs")
---> 21 cls.driver.set_window_size(1440, 900)
22 cls.commonOp = commonOp(cls.driver, cls.live_server_url + settings.STATIC_URL + 'index.html')
23 cls.customDriver = customDriver(cls.driver)
ipdb> <- INPUT SPEED = SLOW! (3-5 seconds hold on key)
我该如何解决这个问题?为什么会这样?
为了重现同样的问题,为python安装phantomjs和selenium
$ pip install selenium
$ npm -g install phantomjs-prebuilt
$ python
>>> from selenium import webdriver
>>> webdriver.PhantomJS('/usr/local/bin/phantomjs')
>>> #try to type here.