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

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.

主站蜘蛛池模板: 思茅市| 中阳县| 石景山区| 喀喇| 永福县| 武乡县| 宁远县| 屏边| 淄博市| 尼勒克县| 孟津县| 潮安县| 乐山市| 贺兰县| 三河市| 左云县| 藁城市| 吐鲁番市| 台北县| 大同县| 新竹市| 论坛| 裕民县| 佛坪县| 遵义县| 长寿区| 连云港市| 凉城县| 汉阴县| 陕西省| 康平县| 阜城县| 应城市| 盘锦市| 东莞市| 新竹县| 宜阳县| 元氏县| 巴南区| 鄂温| 尤溪县|