phantomjs

'Can't find module fs' when running casperjs on js file

对着背影说爱祢 提交于 2019-12-06 07:31:09
I am trying to run CasperJS on a javascript file that I have, and when I run > casperjs index.js it says 'CasperError: Cant find module fs'. The first line of index.js is var fs = require('fs'); I have node, casperjs, and phantomjs installed, why can't it find fs? If I am correct, fs is Node's file system? UPDATE: I added nodejs to my $PATH, but still no luck. Did you install the PhantomJS/CasperJS modules as well as the node fs module in your project? They don't seem to mix very well. I ran into an issue where installed all of these modules and I was getting the same error message you

Selenium GhostDriver/PhantomJS: File not getting uploaded using sendKeys() / Javascript

醉酒当歌 提交于 2019-12-06 07:23:18
问题 I am running a headless script using PhantomJSDriver/GhostDriver and trying to upload a file on gmail while composing an email. Tool: Selenium with PhantomJS/GhostDriver. The html code is as below: Click the "Browse" button to select a file. Click "Done" when you're finished.</table><table width=100% cellpadding=2 cellspacing=0 border=0> <tr><td align=right>1. </td><td> <input name="file1" type=file size=42><tr><td align=right>2. </td><td> <input name="file2" type=file size=42><tr><td align

Switch window on Selenium

早过忘川 提交于 2019-12-06 06:59:29
问题 I am using Selenium with PhantomJS in Python. I need to open a new window and control it. For testing purposes, I'm doing so: from selenium import webdriver driver = webdriver.PhantomJS() driver.get('http://www.google.com.br') handle = driver.execute_script('return window.open("http://www.pudim.com.br/", "any", "height = 450, width = 800, menubar=yes,scrollbars=yes,toolbar=yes,location=no,resizable=yes");') driver.switch_to.window(driver.window_handles[1]) print(driver.current_url) The above

Phantomjs integration with Google App Engine

元气小坏坏 提交于 2019-12-06 06:35:03
问题 Hi I like to know if it is possible to run phantomjs on Google App Engine. My use case is to use Phantomjs to take snapshots of html pages served on GAE using a cron job. Has this been done before ? 回答1: Google App Engine supports a number of language runtimes (Java, Python, PHP and Go), but you can use the Managed VMs feature of Google App Engine to run anything in a Docker container (such as PhantomJS), and you can also use Google Compute Engine to get a VM where you can also install

getting selenium, ghostdriver, phantomJS working on windows 7

不想你离开。 提交于 2019-12-06 06:33:44
I am using selenium-2.34 and phantomJS-1.9.1-windows however when i try to use: import org.openqa.selenium.phantomjs.PhantomJSDriver; import org.openqa.selenium.phantomjs.PhantomJSDriverService; I can see that it does not detect org.openqa.selenium.phantomjs getting this error The import org.openqa.selenium.phantomjs cannot be resolved I was under the impression that GhostDriver was embedded in PhantomJS - https://github.com/detro/ghostdriver does anyone know what could be wrong with my setup? EDIT: Could this be due to a path issue, do i need to supply some way for selenium to pick up these

How use --config with CasperJS

江枫思渺然 提交于 2019-12-06 06:29:40
I've read the Casper documentation and they say that ALL PhantonJS cli options is available on CasperJS but I am trying to use --config=/path/to/config.json and is not working. Is there a way to fix this or do something similar since I don't want to be editing the configs on terminal. casperjs --config=config.json test.js My config.json file: { "load-images" : false } My test.js file: var casper = require('casper').create(); casper.start('http://www.example.com/', function(){ this.capture('image.png'); }) .run(); That code above is loading the images. Of course this is a simple example and

Make phantomjs run all '*.js' files in the current directory

て烟熏妆下的殇ゞ 提交于 2019-12-06 06:09:36
I want to write a script to call phantomjs on a bunch of test scripts in a directory. This script runs the first test and then exits. #!/bin/bash find . -maxdepth 1 -name '*.js' -type f -exec phantomjs {} + Executing a similar command with echo , like find . -maxdepth 1 -name '*.js' -type f -exec echo {} + prints (as expected) all the filenames in the directory. How can I make phantomjs run all .js files in the current directory? Is this a bash problem or a phantomjs problem? AFAIK phantomjs will only support one file at the time. You need to tell find to call phantomjs for each found file: #!

How to include JavaScript file in Java program

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 05:52:44
I have this script file created using phantomjs var webPage = require('webpage'); var page = webPage.create(); page.open(URL, function (status) { var content = page.content; console.log('Content: ' + content); phantom.exit(); }); now I want to use this script in a Java program but I can't. I do this in my project ScriptEngineManager s = new ScriptEngineManager(); ScriptEngine se = s.getEngineByName("JavaScript"); se.eval(new FileReader("myScript.js")); but `this is the result Exception in thread "main" javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError:

案例:网站模拟登录

[亡魂溺海] 提交于 2019-12-06 04:59:17
# coding=utf-8 from selenium import webdriver import time # 如果没有在环境变量指定PhantomJS位置 driver = webdriver.PhantomJS(executable_path=r'/Users/loaderman/Documents/phantomjs-2.1.1-macosx/bin/phantomjs') driver.get("http://192.168.0.195:8080/web/index.html") # 输入账号密码 driver.find_element_by_name("username").send_keys("admin") driver.find_element_by_name("password").send_keys("admin") # 模拟点击登录 driver.find_element_by_xpath("//button[@class='layui-btn layui-btn-fluid']").click() # 等待3秒 time.sleep(3) # 生成登陆后快照 driver.save_screenshot("login.png") with open("login.html", "w") as file: file.write(driver.page

Installing casperJS and phantomJS in WIndows Apache 2.4 to pass data to PHP

孤街醉人 提交于 2019-12-06 04:41:53
I am attempting to run my casperjs script by clicking a Run button in a website. My local set up is PHP 5.5.14 with Apache 2.4 on Windows7 [properly running; tested with php page]; and my question is: how do I properly install casperJS and phantomJS so that its PATH is recognized when I execute the script. I need to know what the path is in Windows to be able to use this: putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs"); . I have gone over the following possible solutions but none of them mention on how to properly install casperJS and phantomJS for the web server to recognize them: