官术网_书友最值得收藏!

There's more...

PhantomJS, in many ways, is very similar to Selenium. It has fast and native support for various web standards, with features such as DOM handling, CSS selector, JSON, Canvas, and SVG. It is often used in web testing, page automation, screen capturing, and network monitoring.

There is one key difference between Selenium and PhantomJS: PhantomJS is headless and uses WebKit.  As we saw, Selenium opens and automates a browser.  This is not very good if we are in a continuous integration or testing environment where the browser is not installed, and where we also don't want thousands of browser windows or tabs being opened.  Being headless, makes this faster and more efficient.

The example for PhantomJS is in the 01/05_events_with_phantomjs.py file.  There is a single one line change:

driver = webdriver.PhantomJS('phantomjs')

And running the script results in similar output to the Selenium / Firefox example, but without a browser popping up and also it takes less time to complete.

主站蜘蛛池模板: 宣武区| 秦安县| 东辽县| 天柱县| 荥经县| 宣恩县| 兴山县| 如皋市| 海宁市| 台南县| 长沙县| 高邑县| 吉首市| 庄河市| 三河市| 电白县| 二连浩特市| 台安县| 青岛市| 姚安县| 同仁县| 安达市| 平塘县| 桃园市| 龙井市| 渑池县| 申扎县| 绥滨县| 巨野县| 扎鲁特旗| 舟曲县| 南宁市| 全州县| 五华县| 水城县| 朝阳区| 大荔县| 阿瓦提县| 洛宁县| 分宜县| 新蔡县|