phantomjs

How to perfectly isolate and clear environments between each test?

久未见 提交于 2019-12-04 08:18:54
I'm trying to connect to SoundCloud using CasperJS. What is interesting is once you signed in and rerun the login feature later, the previous login is still active. Before going any further, here is the code: casper.thenOpen('https://soundcloud.com/', function() { casper.click('.header__login'); popup = /soundcloud\.com\/connect/; casper.waitForPopup(popup, function() { casper.withPopup(popup, function() { selectors = { '#username': username, '#password': password }; casper.fillSelectors('form.log-in', selectors, false); casper.click('#authorize'); }); }); }); If you run this code at least

HTML rendering on server with Node.js

大憨熊 提交于 2019-12-04 08:15:54
Suppose I've got a web page, which contains nothing but a javascript reference. When a browser loads the page it runs the javascript, which does the actual rendering. The javascript is large, complex, and makes a lot of XHR calls. Now I need to make this page searchable , i.e. render the page on the server. I tried to load the page in phantomJS but the it was slow and sometimes did not complete the whole page. So I'm wondering if there is an alternative. Ideally I need a node.js script to load a web page by URL run the page javascript and then serialize the DOM created by the javascript to

Troubleshoot PhantomJS code to sign in to Instagram

烈酒焚心 提交于 2019-12-04 08:05:19
I've written this PhantomJS script to automate signing in to Instagram. It can successfully fill in the form fields and press the submit button, but it always gets redirected back to the logon screen with the following message: Your username or password was incorrect. I am 100% positive that the credentials are correct, and I tried it with multiple Instagram accounts. I'm running the script on a Mac from terminal: $ phantomjs --ssl-protocol=any --cookies-file=cookies.txt script.js username password Note the --ssl-protocol=any option. Without it PhantomJS can't even open the login page because

selenium PhantomJS send_keys doesn't work

烈酒焚心 提交于 2019-12-04 08:03:08
I am using selenium and PhantomJS for testing. I followed Selenium's simple usage, but send_keys doesn't work on PhantomJS, it works on Firefox. Why? I have to use button.click() instead? #!/usr/bin/python # -*- coding: utf-8 -*- import sys reload(sys) sys.setdefaultencoding('utf-8') from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.PhantomJS() driver.get("http://www.python.org/") elem = driver.find_element_by_id("q") elem.clear() elem.send_keys("python") elem.send_keys(Keys.RETURN) # button = driver.find_element_by_id('submit') # button.click()

WebDriver PhantomJS Unable to find element, but works fine with Firefox

扶醉桌前 提交于 2019-12-04 07:47:18
I have been banging my head into the wall for a long time now so I thought I would ask the "experts" why the below code would not work (entering password) with PhantomJS but works just fine with Firefox. The most disturbing of all is that one field entry (username) is successful but the second would not work at all. The page loads just fine and I have included test code to verify other components are loaded just fine. See code below: import java.io.File; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.phantomjs.PhantomJSDriver; public

Phantom JS Error with youtube video

為{幸葍}努か 提交于 2019-12-04 06:59:38
Phantom JS Version: 1.9.1 Poltergeist Version: 1.3.0 Starting today youtube embedded videos now give a poltergeist error when running javascript tests. My youtube code is just the default embed youtube code. Here's a example: <iframe width="560" height="315" src="//www.youtube.com/embed/AW9Z3cGOlGM?rel=0" frameborder="0" allowfullscreen></iframe> And the errors I get just from visiting that page while enabling javascript is: Failure/Error: page.find(".container.registrations.false.government")["style"].should have_content("test.jpg") Capybara::Poltergeist::JavascriptError: One or more errors

Phantom.js / Casper.js with rotating proxy?

邮差的信 提交于 2019-12-04 06:19:15
I have a simple goal: load webpages with either phantom.js (out of the box) or casper.js (nice and easier) but using proxy and rotate it from a list if current one is bad (i.e. webpage loads fail or something like that). I know casper.js has --proxy param but it dictates the user to specify only ONE proxy and use it during runtime. Question #1 is: how to rotate proxy on the fly programmatically? I did some research and found this node-requester but it's not integrated with casper.js . I tried to extract out just the proxy feature in the code but didn't really understand how it works in the

Can not deliver image files through phantomjs webserver

我是研究僧i 提交于 2019-12-04 06:14:08
i am trying tp get phantomjs webserver works for me I want to serve 2 files, html file , and a png image file, the html file is served well and rendered correctly in the browser, but the png file is not here is the code for the server var fs = require('fs'); function loadFile(name){ if(fs.exists(name)){ console.log(name+ " File exist"); return fs.open(name,"r"); }else { console.log("File do not exist"); } } var server, service; server = require('webserver').create(); service = server.listen(8080, function (request, response) { if(request.url.split(".")[1] === "html" ){ var fi = loadFile(".

selenium with PhantomJs wait till page fully loaded?

99封情书 提交于 2019-12-04 06:11:24
I use Selenium with Phantomjs, and want to get the page content after the page fully loaded. I tried http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp but it seems not working with phantomjs Explicit wait: using (IWebDriver driver = new PhantomJSDriver()) { IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(30.00)); wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete")); driver.Navigate().GoToUrl(url); content = driver.PageSource; driver.Quit(); } Another test: using (IWebDriver

Responsive design testing with PhantomJS

早过忘川 提交于 2019-12-04 05:25:06
I have a javascript application (RequireJS with Backbone ) which I am testing using PhantomJS with Jasmine. After much pain I finally have simple tests running. I am using a test runner based on the one found here run-jasmine.js . My application is responsive in that as the viewport width changes, the widths of various DOM elements will also change. I am aware that I can set the viewport width in 'run-jasmine.js' when I create the 'page' for testing. What I would like to know is.....Are you able to somehow loop through a series of viewport widths in a single test suite. Using 'run-jasmine.js'