Selenium 是否支持无头浏览器测试? [英] Does Selenium support headless browser testing?

查看:42
本文介绍了Selenium 是否支持无头浏览器测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在看 Selenium Server,我似乎没有注意到支持无头浏览器测试的驱动程序.

I'm looking at Selenium Server at the moment, and I don't seem to notice a driver that supports headless browser testing.

除非我弄错了,否则它不支持.如果您使用的是 X,您可以创建一个虚拟帧缓冲区来隐藏浏览器窗口,但这并不是真正的无头浏览器.

Unless I'm mistaken, it doesn't support it. If you're on X, you can create a virtual framebuffer to hide the browser window, but that's not really a headless browser.

谁能教教我?Selenium 是否支持无头浏览器测试?

Can anyone enlighten me? Does Selenium support headless browser testing?

推荐答案

你不需要使用 PhantomJS 作为 Selenium 的替代品.Selenium 包含一个 PhantomJS webdriver 类,它运行在 GhostDriver 平台上.只需将 PhantomJS 二进制文件安装到您的机器上.在python中,你可以使用:

you need not use PhantomJS as an alternative to Selenium. Selenium includes a PhantomJS webdriver class, which rides on the GhostDriver platform. Simply install the PhantomJS binary to your machine. in python, you can then use:

from selenium import webdriver
dr = webdriver.PhantomJS() 

瞧.

这篇关于Selenium 是否支持无头浏览器测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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