Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8606869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:12:06+00:00 2026-06-12T03:12:06+00:00

I am trying to navigate to urls that are created from the script itself.

  • 0

I am trying to navigate to urls that are created from the script itself.

This sample code does not work as (I had) expected. Can’t figure out why 🙁

var casper = require('casper').create({
    viewportSize:{
        width:1024, height:768
    },
    pageSettings:{
        userAgent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11'
    },
    verbose:true
});

casper.on('open', function (location) {
    console.log(location + ' loaded');
});

casper.start('http://www.google.com', function() {
    this.test.assertTitle('Google', 'Google homepage title is the one expected');
});

casper.mytest = '';

casper.then(function () {
    casper.mytest = 'http://www.yahoo.com';
});

casper.thenOpen(casper.mytest, function() {
    this.test.assertTitle('Yahoo', 'Yahoo homepage title is the one expected');
});

casper.run(function () {
        casper.exit();
    }
);

The result is that the second page does not load:

http://www.google.com loaded
PASS Google homepage title is the one expected
 loaded    
FAIL Yahoo homepage title is the one expected
#    type: assertTitle
#    subject: ""
#    expected: "Yahoo"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:12:08+00:00Added an answer on June 12, 2026 at 3:12 am

    I think, the reason for your problem is that at the moment, when you register thenOpen step for Yahoo the variable casper.mytest is empty. This value gets into the CasperJS’s map of steps at this moment, and it does not matter that you change the source variable in the step before.

    The blog post Webscraping with CasperJS and PhantomJS may be helpful as an example of fetching dynamically constructed urls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying this and it does not seem like it wants to
When trying to navigate from index.html page to purchase.html, this A Network error occurred
I am trying to build a simple script which must be able to navigate
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I'm trying to grab the Web.UI.WebControls.HyperLink object itself via javascript so that I can
I am trying to enable sluggified URLs in Django of the form that SO
I am trying to add controls to the page from the code behind in
I am trying to navigate a table row that has been clicked, to extract
I am trying to navigate to a page from a ScrollViewer control: <Button x:Name=btnViewMenu

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.