Rom*_*her 6 python selenium phantomjs
我正在尝试帮助在别人设置上运行我的selenium(Python绑定版本2)测试.
它适用于Firefox esr(在两台机器上),它可与我机器上的最新幻像一起使用.它挂在他的机器上.
只有明显的区别是他在Windows 10上,而我在Windows 7上.我不认为这是防火墙或代理,因为我负责它(为防火墙启用所有内容并运行它--proxy-type=none).
我该如何调试?
更多细节可能会有所帮助。您收到错误消息吗?你的代码怎么样?
无论如何,一些可能有助于弄清楚正在发生的事情的想法是:
将窗口大小设置为适合您的测试的大小。
driver.set_window_size(900, 800)
Run Code Online (Sandbox Code Playgroud)
保存截图。
driver.save_screenshot('screen.png')
Run Code Online (Sandbox Code Playgroud)
检查页面来源是否符合您的期望。
with open('temp.html', 'w') as f:
f.write(driver.page_source)
Run Code Online (Sandbox Code Playgroud)
您可以尝试看看升级 Selenium 是否有帮助。
pip install selenium --upgrade
Run Code Online (Sandbox Code Playgroud)
您可以通过下载并指定路径来测试其他版本的 PhantomJS 。1.9.8 版本帮助我绕过了过去的一些安全限制。
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"
),
},
)
Run Code Online (Sandbox Code Playgroud)
请让我知道这可不可以帮你!
| 归档时间: |
|
| 查看次数: |
521 次 |
| 最近记录: |