phantomjs

Selenium with PhantomJS: Form being validated but not submitted

允我心安 提交于 2020-01-15 18:48:22
问题 I'm having a strange problem submitting a form through Selenium Webdriver's PhantomJS API. Upon clicking the submit button, the form gets validated (are the username and password too short, or blank, etc.), but it does not get ultimately submitted. That is, if I submit an invalid form, and check the screenshot, there are alert notifications. If I submit a valid form, nothing happens. The JS on the page is supposed to validate the form, then submit it, when the submit button is clicked. A

PhantomJS 与python的结合

我怕爱的太早我们不能终老 提交于 2020-01-15 08:25:25
本文转载自: https://www.cnblogs.com/zzhzhao/p/5380376.html 作者:zzhzhao 转载请注明该声明。 待完善 一.简介 PhantomJS是一个基于webkit的JavaScript API。它使用QtWebKit作为它核心浏览器的功能,使用webkit来编译解释执行JavaScript代码。任何你可以在基于webkit浏览器 做的事情,它都能做到。它不仅是个隐形的浏览器,提供了诸如CSS选择器、支持Web标准、DOM操作、JSON、HTML5、Canvas、SVG等, 同时也提供了处理文件I/O的操作,从而使你可以向操作系统读写文件等。PhantomJS的用处可谓非常广泛,诸如前端无界面自动化测试(需要结合 Jasmin)、网络监测、网页截屏等。 二.PhantomJS安装   我的是win7系统,在下面的网站选择合适的版本安装 http://phantomjs.org/   装好解压后,把文件夹bin中的phantomjs.exe移到 python 文件夹中的Scripts中,至此,就已经在Win的环境下配置好了环境。 三.小测试 from selenium import webdriver driver = webdriver.PhantomJS() driver.get( " http://hotel.qunar.com/ "

how to screenshot a div using phantomJS

痞子三分冷 提交于 2020-01-15 05:17:26
问题 Hi does anyone here can help me to screenshot my div using phantomJS? How can i Screenshot my #dropzone then append it on the same page? Please help. 回答1: There are two ways you can partially render a webpage. 1) Make an extra page with just the div, screenshot it using render, and use the result on your actual page. 2) Use the clipRect functionality (as described here): var clipRect = document.querySelector(selector).getBoundingClientRect(); page.clipRect = { top: clipRect.top, left:

Ensuring IE-9 compatibility while end to end testing using phantomJS

寵の児 提交于 2020-01-15 03:10:47
问题 I am using PhantomJS (headless end to end testing),selenium webdriver,grunt(task runner) for my application testing. My requirement is that the application should be compatible with IE-9. I have to do headless testing because I'm using jenkins for continuous integration. How do i make sure that my application will run perfectly on IE-9 while testing on phantomJS ? 回答1: You can't use PhantomJS for testing compatibility with Internet Explorer, because it is a Webkit browser. Since you're using

Why PhantomJS render page use window.setTimeout

我的未来我决定 提交于 2020-01-14 12:58:08
问题 I am currently using PhantomJS for some doc's reports and looking in some examples i found this. window.setTimeout(function () { page.render(output); console.log(output); phantom.exit(); }, 200); I wonder why using window.setTimeout?? It affect web rendering?? Thanks... Nick. 回答1: The page.open callback is invoked only when the page is loaded. This does not means that everything has been loaded in your page and the js has been fully executed. In addition, the js on the web page may not be

Jasmine/PhantomJs spec runner

泄露秘密 提交于 2020-01-14 08:50:30
问题 I cannot get my test to run using phantomJs. gulp task var jasminePhantomJs = require('gulp-jasmine2-phantomjs'); gulp.task('test', function() { return gulp.src('./SpecRunner.html') .pipe(jasminePhantomJs()); }); SpecRunner.html <script src="lib/jquery.min.js"></script> <script src="lib/lodash.min.js"></script> <script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script> <script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-html.js"></script> <script type="text

CasperJS: how to exit script execution?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 07:59:07
问题 Yesterday I've written my first tests with CasperJS and I find it amazing. The problem is that I couldn't find a way to exit the script execution (ie: casperjs doesn't exist so I can get back access to my console). I've found an workaround by adding a final test like so casper.test.begin('Exit', function suite(test) { casper.exit(); }); Regarding this technique I have 2 questions Is there a better way? How would that impact the output of the results to xunit file? 回答1: casper.then(function()

CasperJS/PhantomJS Segmentation fault

孤者浪人 提交于 2020-01-14 06:27:07
问题 I have a script which opens the urls in the links array and for each url it extracts the links in that url and inserts the new links to the array links(addLinks function). The code results in segmentation fault and it happens when it calls this.start to open a valid url (3rd line of the code). Is it a problem with casperjs or my code? Another interesting point is that it always prints 'OK, it is loaded' after the 'Page title: ' while according to the code they should be printed in reverse

Mirroring a webpage recursively after JS execution

末鹿安然 提交于 2020-01-14 06:12:17
问题 I'm trying to mirror a webpage recursively, e.g. getting all pages on one webpage. All webpages are in subfolders of just one folder, therefore I could easily mirror all webpages using wget: wget --mirror --recursive --page-requisites --adjust-extension --no-parent --convert-links https://www.example.com/ However, the page is mirrored before some JS scripts are executed, and those JS scripts don't get mirrored. I need to mirror them too, somehow, because they change the webpage's DOM. Another

Mirroring a webpage recursively after JS execution

为君一笑 提交于 2020-01-14 06:11:21
问题 I'm trying to mirror a webpage recursively, e.g. getting all pages on one webpage. All webpages are in subfolders of just one folder, therefore I could easily mirror all webpages using wget: wget --mirror --recursive --page-requisites --adjust-extension --no-parent --convert-links https://www.example.com/ However, the page is mirrored before some JS scripts are executed, and those JS scripts don't get mirrored. I need to mirror them too, somehow, because they change the webpage's DOM. Another