phantomjs

How to see stdout of a phantomjs child process using node.js?

≡放荡痞女 提交于 2019-11-30 23:31:24
In the following node.js code, I normally have to wait for the phantomjs child process to terminate to get the stdout. I am wondering if there is any way to see the stdout while the phantomjs child process is running? var path = require('path') var childProcess = require('child_process') var phantomjs = require('phantomjs') var binPath = phantomjs.path var childArgs = [ path.join(__dirname, 'phantomjs-script.js'), ] childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) { // handle results }) You can spawn PhantomJS as a child process and subscribe to its stdout and stderr

Handling Redirection w/ PhantomJS + Selenium

落爺英雄遲暮 提交于 2019-11-30 23:23:40
I currently run browser tests via PhantomJS + Selenium in Python. desired_capabilities = dict(DesiredCapabilities.PHANTOMJS) desired_capabilities["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36") driver = webdriver.PhantomJS(executable_path="./phantomjs", desired_capabilities=desired_capabilities) driver.get('http://google.com') This works fine, unless the page I'm trying to get has a redirect on it. Example: https://login.vrealizeair.vmware.com/ In this case, the get doesn't work

How to Login by filling the form in CasperJs

佐手、 提交于 2019-11-30 22:57:03
问题 Following is the hlml of the login form that I have <div class="login_area_user"> <form method="post" action="https://www.tradus.com/login?dest_url=https://www.tradus.com/cart/select-address" id="user-login"> <input type="hidden" value="1" name="form_submit"> <h3 style="display:inline-block;">Already a Member</h3> <p id="login-main-center-right-descp">You can use tradus login id and password</p> <div class="login-row"> <label class="colorBlack">Email / Login*</label> <input class="login-field

How to click on selectbox options using PhantomJS

左心房为你撑大大i 提交于 2019-11-30 21:21:14
There is the page testkrok.org.ua with a consistent selection of parameters. So, I need to create a series of 5 clicks on each of the options of 5 select boxes that depend on each other. document.querySelector('select.se1')[3] document.querySelector('select.se2')[1] document.querySelector('select.se3')[1] document.querySelector('select.se4')[1] document.querySelector('select.se5')[3] to redirect to the page with tests. But on snapshot taken after the first click the second panel does not appear? Maybe I don't hit the the element? var page = require('webpage').create(); page.open('https:/

PhantomJS unexpectedly exits on Selenium : WebDriverException with status code 127

最后都变了- 提交于 2019-11-30 20:44:35
I am using a global PhantomJS on my Mac OS X for multiple Javascript and Python selenium projects. For the first time, I set up a virtual environnement using virtualenv : virtualenv Python3.5 Path/To/MyEnvironnement Then : Path/To/MyEnvironnement . bin/activate which phantomjs ... returns my global selenium : /Users/Me/.npm-packages/bin/phantomjs But every time I call : driver = webdriver.PhantomJS(executable_path=r'/Users/Me/.npm-packages/bin/phantomjs') I get this error : Traceback (most recent call last): File "/Path/To/MyEnvironnement/script/spider/crawl/Urls.py", line 194, in <module>

Can't find variable: page in PhantomJS

对着背影说爱祢 提交于 2019-11-30 19:57:39
I'm beginner in test, both in Unit Test and UI Test I'm trying to create a UI test for my login page using following code: console.log("Teste de Login"); var page = require('webpage').create(); page.open('http://localhost/login', function(status) { console.log("Page loadeed"); if(status === "success") { page.render('example1.png'); } page.evaluate(function() { // $("#numeroUsuario").val("99734167"); document.getElementById('numeroUsuario').value = "99734167"; page.render('exampl2.png'); // $("#formLogin").submit(); page.render('example3.png'); }); phantom.exit(); }); But this code returns the

图片懒加载

送分小仙女□ 提交于 2019-11-30 19:26:51
一.图片懒加载 什么是图片懒加载? 案例分析:抓取站长素材http://sc.chinaz.com/中的图片数据 #!/usr/bin/env python # -*- coding:utf-8 -*- import requests from lxml import etree if __name__ == "__main__": url = 'http://sc.chinaz.com/tupian/gudianmeinvtupian.html' headers = { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36', } #获取页面文本数据 response = requests.get(url=url,headers=headers) response.encoding = 'utf-8' page_text = response.text #解析页面数据(获取页面中的图片链接) #创建etree对象 tree = etree.HTML(page_text) div_list = tree.xpath('//div[@id="container"]

Can I get the original page source (vs current DOM) with phantomjs/casperjs?

眉间皱痕 提交于 2019-11-30 19:19:03
I am trying to get the original source for a particular web page. The page executes some scripts that modify the DOM as soon as it loads. I would like to get the source before any script or user changes any object in the document. With Chrome or Firefox (and probably most browsers) I can either look at the DOM (debug utility F12) or look at the original source (right-click, view source) . The latter is what I want to accomplish. Is it possible to do this with phantomjs/casperjs? Before getting to the page I have to log in. This is working fine with casperjs. If I browse to the page and render

PhantomJS open one page after another

做~自己de王妃 提交于 2019-11-30 19:14:51
I used this example to create a phantomjs code to login to website. var page = require('webpage').create(); page.open("http://www.facebook.com/login.php", function(status) { if (status === "success") { page.onConsoleMessage = function(msg, lineNum, sourceId) { console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")'); }; page.evaluate(function() { console.log('hello'); document.getElementById("email").value = "email"; document.getElementById("pass").value = "password"; document.getElementById("u_0_1").click(); // page is redirecting. }); setTimeout(function() {

Issues running casperjs with phantomjs#2.0.0 on Mac (Yosemite)

北城余情 提交于 2019-11-30 19:11:26
I'm trying to run CasperJS having PhantomJS#2.0.0 on a Mac(Yosemite) . When trying to run CasperJS I´m getting the following message: "CasperJS needs PhantomJS v1.x /usr/local/Cellar/casperjs/1.1-beta3/libexec/bin/bootstrap.js:91 in __die" How can I make it run? Has anyone got it working? Currently there is no newer version than 1.1-beta3 released which contains this check. The simplest fix would be to open the bin/bootstrap.js file and remove these lines or replacing the lines that are currently in the master branch : (function (version) { // required version check if (version.major === 1) {