Selenium Phantomjs浏览器在启动时挂起.我该如何调试? [英] Selenium Phantomjs browsers hangs on startup. How do I debug it?

查看:86
本文介绍了Selenium Phantomjs浏览器在启动时挂起.我该如何调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试帮助在其他安装程序上运行我的硒(Python绑定版本2)测试.

I'm trying to help run my selenium (Python bindings version 2) tests on someone else setup.

它与Firefox esr兼容(在两台机器上),并且与我的机器上最新的phantomjs一起使用.它挂在他的机器上.

It works with the Firefox esr(on both machines), it works with the latest phantomjs on my machine. It hangs on his machine.

只有一个明显的区别是他在Windows 10上和我在Windows 7上.我认为这不是防火墙或代理引起的,因为我已经照顾了它(为防火墙启用所有功能并使用--proxy-type=none运行它)

Only obvious difference between is he's on Windows 10 and I'm on Windows 7. I don't think it's the firewall or proxy cause I took care of it ( enabling everything for the firewall and running it with --proxy-type=none).

我如何调试它?

推荐答案

更多详细信息可能会有所帮助.您是否收到错误消息?您的代码怎么样?

More details could help. Do you get an error message? How is your code?

无论如何,一些可能有助于弄清正在发生什么的想法是:

In any case, some ideas that may help to figure out what is happening are:

将窗口大小设置为适合您的测试的大小.

Set the window size to something appropriate for your tests.

driver.set_window_size(900, 800)

保存屏幕截图.

driver.save_screenshot('screen.png')

检查页面源是否符合您的期望.

Check if the page source matches your expectations.

with open('temp.html', 'w') as f:
    f.write(driver.page_source)

您可以尝试查看升级Selenium是否有帮助.

You may try to see if upgrading Selenium helps.

pip install selenium --upgrade

您可以通过下载并指定路径来测试其他版本的PhantomJS .版本1.9.8过去帮助我绕过了一些安全限制.

You may test other versions of PhantomJS, by downloading and specifying the path. Version 1.9.8 helped me with bypassing some security restrictions in the past.

driver = webdriver.PhantomJS(
    executable_path='/path/to/the/downloaded/phantomjs19',
    # you can specify args, such as:
    service_args=[
        '--ignore-ssl-errors=true', 
        '--ssl-protocol=any', 
        '--web-security=false',
    ],
    # and also other capabilities:
    desired_capabilities={
        'phantomjs.page.settings.resourceTimeout': '5000',
        'phantomjs.page.settings.userAgent': (
            "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 "
            "(KHTML, like Gecko) Chrome/15.0.87"
        ),
    },
)

请让我知道这是否有帮助!

Please, let me know if this helps!

这篇关于Selenium Phantomjs浏览器在启动时挂起.我该如何调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆