page.evaluate not working but page.exeute_script showing results - html5-canvas

I have been using phantomjs to render canvas element on my page using ThreeJs.
Earlier I was building the page myself, but that did not gave option of adding a background image through system url.
Now after that I started using a localhost url, which did not worked when I used page.evaluate();
BUT to my surprise when I use Ruby/Watir browser with selenium to do the same operation using execute_script method, it works.
I want to know what is it doing differenty that I implement in phantomjs script instead of having watir/selenium etc.
Thanks in advance.

Related

Mechanize can't find form

I'm having some problem accessing the form element on a page I'm getting using Mechanize.
username_page = agent.get 'https://member.carefirst.com/mos/#/home'
username_form = username_page.form_with(name: 'soloLoginForm')
username_form is nil. (username_page does have the page). The page definitely has a form and the field is #soloLoginForm, but username_page.body has no form element.
I'm guessing this is some async or dynamic issue. I'm able to grab the form with poltergeist, and I'm looking into doing all my form filling with capybara/poltergeist, but I wonder if there's something simple I'm missing that will allow me to use mechanize, as I'd planned.
It seems to be that 'https://member.carefirst.com/mos/#/home' uses Angular to render elements of the page and AngularJS requires Javascript support in the browser or in your case Capybara needs a driver with Javascript support.
Mechanize doesn't support Javascript, check this old SO thread. This is probably the reason why it works when you try with poltergeist.
Check: https://github.com/teamcapybara/capybara#drivers
As stated in the answer by #hernanvicente the page is using Angular and requires JS (which mechanize does not support). However, you really want to be using selenium with headless Chrome rather than Poltergeist nowadays. Poltergeist is equivalent to about a 7 year old version of Safari (due to PhantomJS, which it uses for rendering, being abandoned) so it doesn't support a lot of JS and CSS used in modern sites. Another advantage of using Selenium with Chrome is that you can easily swap between headless and headed to see what's happening when you need to debug things.

HTML/Javascript login page using CasperJS

I've been trying to login to write a script using CasperJS that logs in to my work's router login page, and I'm a little lost...
The html for the login page is here: https://dl.dropboxusercontent.com/u/30314127/help.rtf
Thanks in advance,
Ronka
I'm not sure anybody is going to write the code you need. Casperjs has pretty good documentation. You need to request the page, find the id's of the login and sendKeys. I haven't run into any issues of not being able to log into a web based application using casper. IF you're completely at a loss I have a video you can watch which enters data into an Ajax application, which shouldn't be too much different than what you're trying to do.
Filling out Ajax forms

How to reset or re-initialize a Jquery plugin being used on AJAX-updated links?

I am using this plugin for adding arrow key navigation to a website
Works great! However, sometimes my links are updated via AJAX and then the highlighting disappears. So I started re-initializing the plugin when my links were updated. I noticed this solved the problem, however now I had multiple copies of the plugin running, thus highlighting multiple buttons at once.
I know there isn't a 'built in' destory method in Jquery, but does anyone have any ideas on how to re-initialize a plugin or at least get rid of the old instance running.
You can see the source code of the plugin on GitHub
The plugin code is simple and I believe what I am trying to achieve is simple as well. Thanks!
The plugin you are using has an update function, call that function as soon as you get the ajax result back.
for example
var $keyNav = $('#navigation a').keynav();
and on ajax success
$keyNav.update();
I haven't tested this code but I think it will work.

Confusing WP page load with AJAX

My site is http://armandwho.com/site
I'm using the Adv. Ajax Page Loader Plugin in order to keep my background vid & music uninterrupted while browsing.
I'm having trouble with the "LOOK" page. When navigating to it from the homepage (1st link), the gallery doesn't load at all. However, when you refresh or go directly to the page URL it works.
Within the plugin, there is an area for jQuery reload codes, which I think will load the needed scripts that don't get loaded when using the nav.
Can anyone make sense of what script I might need to "reload" to get my gallery working with this Ajax plugin?
Help is supremely appreciated!
Joe
I loved the music, so I decided to look into the problem a bit.
I stepped through the code for the plugin as it tried to load the page and came across this line:
//Nothing like good old pure JavaScript...
document.getElementById(AAPL_content).innerHTML = output;
..which is a problem because the javascript in the script tags isn't going to be run. You could change it to:
//Nothing like good old pure JavaScript...
jQuery(document.getElementById(AAPL_content)).html(output);
..and jQuery will handle the dirty work.

Executing AJAX scripts within an AJAX response

I'm having trouble using AJAX page updates along with other AJAX scripts.
During a normal page load, the AJAX scripts (picture scrolling and picture thumbnails) work fine. But when I update a page with AJAX, these scripts (usually loaded in the header of the initial page load) stop working.
I am wondering if this is specific to these scripts and I need to look into them deeper to resolve/re-write or if I am missing something more generic in combining AJAX page updates with AJAX scripts the returned code relies on.
Embedded javascript runs fine.
Thanks for your ideas!
PS: The scripts I am using are from www.dynamicdrive.com are:
1) stepcarousel (http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm) and
23) thumbnailviewer (http://www.dynamicdrive.com/dynamicindex4/thumbnail.htm) from the
Try doing this on Firefox, using the Firebug debugger, so you can single-step through and determine what is going on with the javascript. If you are using IE8 then you can hit F12 and bring up the debugger for that environment also.
Once you have some idea what is going on then you can explain what you are seeing, what browsers you have tried and you will get more help.

Resources