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

  • SEARCH
  • Home
  • 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 9267937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:40:44+00:00 2026-06-18T14:40:44+00:00

I am writing an end-to-end test in Angular, and I would like to verify

  • 0

I am writing an end-to-end test in Angular, and I would like to verify the position of a DOM element in relation to another DOM element. Fortunately, the Angular E2E DSL has a passthrough method for jQuery’s offset() method. Perfect for my use case!

However, I’m confused how to use the object that this method returns. The call to offset() returns an object with the properties top and left. When I try to access these properties in the test, Angular complains.

This code works great:

expect(element("#anID").offset()).toEqual({"top":100,"left":100});

This code doesn’t work, and throws an error:

expect(element("#anID").offset().top).toEqual(100);

TypeError: Cannot read property 'name' of undefined
    at Object.angular.scenario.matcher.(anonymous function) (http://localhost:8000/test/angular/angular-scenario.js:23994:41)
    at Object.executeStatement (http://localhost:8000/test/angular/angular-scenario.js:23960:30)
    at Object.chain.(anonymous function) [as toEqual] (http://localhost:8000/test/angular/angular-scenario.js:23968:37)
    at Object.<anonymous> (http://localhost:8000/test/E2E-scenarios.js:78:53)

How do I use the return from offset() to construct an expectation roughly like:

expect(element("#anID").scrollTop() - element("#anotherID").offset().top).toEqual(100);

Update

After the back and forth with Josh David Miller, I see my real question is: how can I get the value of an angular.scenario.Future object outside of an expect() call, so I can use it as the basis of other expectations?

  • 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-18T14:40:45+00:00Added an answer on June 18, 2026 at 2:40 pm

    Found the answer on the Angular mailing list. Something like this will work for using multiple angular.scenario.Future object values in a single expectation:

      it('async expectation', function() {
        browser().navigateTo('index.html');
        var relativeElement = element("#anID").prop( 'offsetTop' )
    
        this.addFuture('ScenarioRunner step title', function(done) {
          expect(element('#anotherID').scrollTop()).toEqual(relativeElement.value - 100);
          done();
        });
      });
    

    There’s a issue open on the angular github repo for integrating this into the ScenarioRunner more elegantly.

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

Sidebar

Related Questions

I often end up writing code like if x == 1 or x ==
I'm writing a test for some existing Ruby code which looks something like module
I'm writing a test app using the twitter gem and I'd like to write
I am currently writing a unit test framework which shall in the end run
I am writing test harness to test a HTTP Post. Test case would send
I am writing front end app that connects to a DB and downloads any
I often end up writing a bit of code twice when using a loops.
I am a front-end developer writing a C# application to export data from an
I am from procedure programming background, end up writing TSQL recently with my new
I'm writing a web based front end to a database (PHP/Postgresql) in which I

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.