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 8796609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:39:47+00:00 2026-06-13T23:39:47+00:00

I’m attempting to create a node.js script using soda.js for organizing and writing Selenium

  • 0

I’m attempting to create a node.js script using soda.js for organizing and writing Selenium scripts. The problem I am running into is that I fundamentally do not understand the soda.js chaining philosophy, especially the and() method and the docs are very weak in explaining how it works.

Imagine the following test case:

var soda = require('soda');
var assert = require('assert');

var browser = soda.createClient({
    host: 'localhost',
    port: 4444,
    url: 'http://www.google.com',
    browser: 'firefox'
});

browser
    .chain
    .session()
    .open("http://www.google.com", function() {
        console.log("open complete");
    })
    .and(function() {
        console.log("and");
    })
    .and(function() {
        return function(browser) {
            console.log("and2");
        }
    }())
    .end(function() {
        console.log("end");
    })

My understanding of the chaining API was that it was to prevent callback hell. So if I call browser.method1().method2().method3(). Then method2 would wait for method one. method3 would wait for method2() etc. Giving you the ease of synchronous, but the functionality of evented.

I expect

open complete
and
and2
end

I get

and
and2
open complete
end

What? It clearly has something to do with the and method, which I thought was declaring your own arbitrary functions, but it doesn’t seem to be following the queue order. As you can see in the test case I’ve tried two methods of declaring the and function, one using a self-executing function closure, and the other with a standard anonymous function. Same result in both cases. How do I get the and() to follow the queue order?

  • 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-13T23:39:48+00:00Added an answer on June 13, 2026 at 11:39 pm

    After much banging my head I was finally able to figure out the way this works only by pouring over the source code for soda on github. Basically the .and() method fires immediately. Each chained request just adds to a queue and it does not begin processing the queue until it hits an .end() call.

    In this way, code inside an and() will always process before the callback from any other call. In this way and() is primarily used for queuing up dynamically defined actions, and it is not useful for responding to previously fired actions, those should be done in callbacks instead.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.