ariya / phantomjs

Scriptable Headless Browser
http://phantomjs.org
BSD 3-Clause "New" or "Revised" License
29.45k stars 5.76k forks source link

PhantomJS/CasperJS crash on clicking a link #11053

Closed nikivanov closed 7 years ago

nikivanov commented 11 years ago

2cent...@gmail.com commented:

Which version of PhantomJS are you using? 1.8.1

What steps will reproduce the problem? casper.start('https://www.peco.com/_layouts/peco/login.aspx');

casper.thenEvaluate(function (user, pass) { $('input[id$="txtUserName"]').val(user); $('input[id$="txtPassword"]').val(pass); }, Username, Password);

casper.thenClick('a[id$="lnkSignIn"]');

What is the expected output? What do you see instead? Crash occurs, but only with valid credentials. Javascript navigates to a page and then redirects to another page. Sorry, I obviously can't provide credentials here

Win 7 64 bit SP1

Did you use binary PhantomJS or did you compile it from source? Latest Binary

Disclaimer: This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, Issue #1053. :star2:   2 people had starred this issue at the time of migration.

nikivanov commented 11 years ago

2cent...@gmail.com commented:

Debug info:

[debug] [phantom] Mouse event 'click' on selector: a[id$="lnkSignIn"] [info] [phantom] Step 4/5: done in 4003ms. [debug] [phantom] Navigation requested: url=https://www.peco.com/_layouts/peco/login.aspx, type=FormSubmitted, lock=true, isMainFrame=true [debug] [phantom] url changed to "https://www.peco.com/_layouts/peco/login.aspx" [debug] [phantom] Navigation requested: url=https://www.peco.com/siteminderagent/forms/login.fcc, type=FormSubmitted, lock=true, isMainFrame=true [debug] [phantom] Automatically injected D:\vsproj\PhantomPecoScraper\PhantomPecoScraper\CasperJS/jquery-1.9.1.min.js client side [debug] [phantom] Successfully injected Casper client-side utilities [debug] [phantom] Navigation requested: url=https://www.peco.com/_layouts/peco/accountslist.aspx, type=FormSubmitted, lock=true, isMainFrame=true [debug] [phantom] Navigation requested: url=https://www.peco.com/Secure/MyAccount/, type=FormSubmitted, lock=true, isMainFrame=true [debug] [phantom] Navigation requested: url=https://www.peco.com/Secure/MyAccount/Pages/default.aspx, type=FormSubmitted, lock=true, isMainFrame=true [debug] [phantom] url changed to "https://www.peco.com/Secure/MyAccount/Pages/default.aspx" [debug] [phantom] Navigation requested: url=about:blank, type=Other, lock=true,isMainFrame=false

nikivanov commented 11 years ago

2cent...@gmail.com commented:

Verified that crash occurs even without using CasperJS

nikivanov commented 11 years ago

2cent...@gmail.com commented:

Reproduced the issue without needing valid credentials:

casper.start('https://www.peco.com/Pages/Home.aspx');

casper.thenClick('a[id$=\"lnkSignIn\"]'); //crashes here

casper.run();

nikivanov commented 11 years ago

2cent...@gmail.com commented:

does not crash on ubuntu 12.10

nikivanov commented 11 years ago

2cent...@gmail.com commented:

does not crash on win7 64bit version 1.7, but crashes on 1.8 and 1.8.1. Seems to be a regression between 1.7 -> 1.8

JohnnyQQQQ commented 11 years ago

jeanphil...@gmail.com commented:

have noticed a similar issue crashing also after [debug] [phantom] Navigation requested: url=about:blank, type=Other, lock=true,isMainFrame=false . also on 1.8

heylookltsme commented 11 years ago

I'm also experiencing this issue. About 50% to 60% of the time, casper hangs when I click a link. The output in verbose mode shows that it hangs right before the "Successfully injected Casper client-side utilities" step.

[debug] [phantom] opening url: http://xxx, HTTP GET [debug] [phantom] Navigation requested: url=http://xxx, type=Other, lock=true, isMainFrame=true [debug] [phantom] url changed to "http://xxx" SOMETIMES HANGS HERE [debug] [phantom] Successfully injected Casper client-side utilities

(Note: I removed the url)

Has there been any progress on this issue? Thanks!

heylookltsme commented 11 years ago

FWIW, I solved the problem I was having by separating all my link clickthru tests into separate files and executing them one by one.

ariya commented 11 years ago

@heylookltsme Please try with version 1.9.1.

heylookltsme commented 11 years ago

@ariya Just tried and it's still an issue for me, unfortunately. Still freezes up in the same spot - right after the "url changed" step.

ariya commented 11 years ago

@heylookltsme Can you come up with a reproduceable test script? Even better if it is using PhantomJS directly.

wahidparis commented 10 years ago

Hi evryone.

i'm having a issue with a casperjs script. I'd be very glad to find some help. Then let me explain what happens to me:

i'm trying to log in on a website hosted in my computer, the mail and password are correct but i can not reach the proper page after i have submited the form. Here is the script I wrote:

var casper = require('casper').create({ verbose: true, logLevel: "debug", localToRemoteUrlAccessEnabled: true, loadPlugins: true, XSSAuditingEnabled: true });

casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');

//Le bloc ci-dessous vérifie que sur la age atteinte, le contenu de la balise tilte soit Nuke // dans le cas contraire elle affiche le message page Nuke indisponible

casper.start('http://nuke.dev.brandministry.fr/login', function() { this.evaluateOrDie(function() { return 'Nuke'.match(document.title); }, 'Page nuke indisponible'); });

//le bloc ci-dessous remplit les champs email et password de la page de loginn casper.then(function() { this.fill('form', { 'email': 'abdelwahid.benslimane@brandministry.fr', 'password': 'jshshshslhih'

}, true);

});

casper.then(function() { this.echo('on est sur la page: '+this.getCurrentUrl());});

casper.run();

and this is the output:

wahid@pluton:~$ casperjs testpage.js [info] [phantom] Starting... [info] [phantom] Running suite: 4 steps [debug] [phantom] opening url: http://nuke.dev.brandministry.fr/login, HTTP GET [debug] [phantom] Navigation requested: url=http://nuke.dev.brandministry.fr/login, type=Other, lock=true, isMainFrame=true [debug] [phantom] url changed to "http://nuke.dev.brandministry.fr/login" [debug] [phantom] Successfully injected Casper client-side utilities [info] [phantom] Step 2/4 http://nuke.dev.brandministry.fr/login (HTTP 200) [info] [phantom] Step 2/4: done in 238ms. [info] [phantom] Step 3/4 http://nuke.dev.brandministry.fr/login (HTTP 200) [info] [remote] attempting to fetch form element from selector: 'form' [debug] [remote] Set "email" field value to abdelwahid.benslimane@brandministry.fr [debug] [remote] Set "password" field value to **** [info] [remote] submitting form to ./login?-1.IFormSubmitListener-login-form, HTTP POST [info] [phantom] Step 3/4: done in 254ms. [debug] [phantom] Navigation requested: url=http://nuke.dev.brandministry.fr/login?-1.IFormSubmitListener-login-form, type=FormSubmitted, lock=true, isMainFrame=true [debug] [phantom] Navigation requested: url=http://nuke.dev.brandministry.fr/home, type=FormSubmitted, lock=true, isMainFrame=true [debug] [phantom] Navigation requested: url=http://nuke.dev.brandministry.fr/login;jsessionid=7D9EAD0DBE80379A5BB0295B3067D6BB, type=FormSubmitted, lock=true, isMainFrame=true [debug] [phantom] url changed to "http://nuke.dev.brandministry.fr/login;jsessionid=7D9EAD0DBE80379A5BB0295B3067D6BB" [debug] [phantom] Successfully injected Casper client-side utilities [info] [phantom] Step 4/4 http://nuke.dev.brandministry.fr/login;jsessionid=7D9EAD0DBE80379A5BB0295B3067D6BB (HTTP 200) on est sur la page: http://nuke.dev.brandministry.fr/login;jsessionid=7D9EAD0DBE80379A5BB0295B3067D6BB [info] [phantom] Step 4/4: done in 569ms. [info] [phantom] Done 4 steps in 578ms

the current url should be http://nuke.dev.brandministry.fr/lhome?1 or http://nuke.dev.brandministry.fr/lhome?2 or http://nuke.dev.brandministry.fr/lhome? followed by any number, instead of http://nuke.dev.brandministry.fr/login;jsessionid=7D9EAD0DBE80379A5BB0295B3067D6BB

I really don't why it doesn't work, this is my first script, i'm trying to learn using casperjs becaus it would be helpful for my job. Thanks in advance

wahidparis commented 10 years ago

has it anything to do with cokies enabling? so how do we enable cookies in a casperjs script? i tried phantom.cookiesEnabled = true; but it doesn't work