2

所以我试图调试我们使用 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)

我怎样才能解决这个问题?为什么会这样?

编辑:我什至在调试时尝试使用 IPython 来查看输入速度问题是否消失,尝试失败。

编辑:复制步骤

为了重现相同的问题,安装 phantomjs 和 selenium for python

$ pip install selenium
$ npm -g install phantomjs-prebuilt
$ python
>>> from selenium import webdriver
>>> webdriver.PhantomJS('/usr/local/bin/phantomjs')
>>> #try to type here.
4

0 回答 0