The second test step threw an error due to an undefined variable, 'ptor

Recently, I've been diving into using Protractor due to the limitations of our current automation framework with Angular. However, I've encountered a puzzling issue where I'm receiving the error message "TypeError: Cannot call method 'waitForAngular' of undefined" in my second describe block for reasons that are not immediately clear to me.

You can find the simplified code I am working with here, along with a stack trace: https://gist.github.com/FrankyBoy/8675399e2236e8235e79

I would greatly appreciate any assistance as I am feeling quite perplexed by this problem.

Answer №1

When using the beforeEach functions, keep in mind that they only run before it functions and not before describe functions. This means that if you're trying to use an object like ptor before it has been initialized with ptor = protractor.getInstance(), you may encounter errors.

To resolve this issue, consider moving the waitForAngular call into an it function as shown below:

describe('Bonus landing page', function () {
  it('should wait', function() {
    ptor.waitForAngular(); // Error: "Cannot call method 'waitForAngular' of undefined"
    // Additional checks can be added here
  });
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Invalid function call detected, transitioning from Reactjs to Nextjs

After spending some time away from the ReactJS world, I decided to make a comeback and try my hand at NextJS. Unfortunately, I ran into an issue with an Invalid Hook Call. I'm in the process of transitioning my ReactJS project to NextJS. To illustrat ...

What steps can be taken to customize the default keyboard shortcuts functionality in Swiper.js?

I am trying to customize the functionality for left/right keys in Swiper.js but I am unable to find a way to do this through the API () It seems that the API only allows you to disable/enable default actions: mySwiper.keyboard.enabled // Whether th ...

Enhancing code readability in vim with custom Javascript syntax highlighting

Is anyone else experiencing issues with VIM's syntax highlighting for Javascript? I have noticed that at times, the highlighting seems to disappear and I have to scroll around to get it adjusted properly. Does anyone know of any workarounds or soluti ...

Find the index of an element in a MongoDB collection

I have a set of files in the following format: { "user": { "username": "string" } "points": 123 } My goal is to determine a user's position within the set. collection.aggregate([ { $sort: { points: -1 } }, // arrange by points descending ...

Using the ng2-translate module to incorporate Angular 2 binding expressions within a string

Currently, I am working on implementing internationalization in Angular 2 using ng2-translate. Within my project, there is a label that contains the following string: <label> Step {{stepNumber}} of {{totalSteps}} </label> In this case, both s ...

JavaScript refuses to connect with HTML

Just starting out in the world of programming, I decided to dive into a Programming Foundations class on Lynda.com. However, after following along for fifteen minutes, I encountered an issue - I couldn't seem to connect my JavaScript file to my HTML f ...

Is it possible to place Google Analytics script in the footer of a website?

I am currently looking to implement Google Analytics on our website, but I have come across conflicting information regarding where to place the script tag. Google advises placing it before the closing </head> tag: http://code.google.com/apis/analy ...

nextAuth.js is failing to access the accessToken, returning only the values {iat, exp, jti} instead

Here is the code I am working with: import NextAuth from "next-auth" import CredentialsProvider from "next-auth/providers/credentials" export default NextAuth({ sectret:process.env.NEXTAUTH_SECRET, session: { strategy: "jw ...

`Execute a JavaScript function prior to form submission`

Before a user submits a form completely and the browser waits for the result, I'd like to execute a JavaScript function. Specifically, I want to overlay the page with a gray layer and show a spinning object while the request is being processed. The fi ...

How can I enhance a JavaScript Calendar with more features?

I recently acquired a JavaScript and jQuery calendar from CodeCanyon, which can be found here. I am now faced with the task of integrating this calendar into my workplace website. The current calendar on our ASPX-based site is limited to read-only functio ...

Fetch Timeout Issue in React Native

I am currently using fetch to retrieve data from a server. Unfortunately, I am facing issues with setting a timeout for the fetch request in case the server does not respond. This is my global fetchData class: fetchGetResp(url, token) { return fetch( ...

Tips for clicking the OK button in an alert box with Protractor

When working with AngularJS, I encounter the need to delete a link which triggers an alert box for confirmation. While attempting e2e testing using protractor, how can I confirm actions within an alert box? I attempted the following code snippet: browse ...

Is it possible to utilize super class methods as decorator methods in Typescript?

I'm working on a project where I aim to create an easily extendible decorator factory, and achieving this would be a great accomplishment. The main goal is to utilize the methods of a superclass as decorators for properties in subclasses. This is ty ...

What is the best way to convert a JSON file into an array of objects using Node.js?

Looking to integrate a JSON file into my code and parse it into an array of objects. Here is an example of the JSON file: { "movies": [ { "title": "Star Wars", "year": 1977, "director": "George Lucas" }, { "title": "T ...

Ways to deactivate just the Clicked button in a mapped over component

Utilizing the request variable, I am displaying an array of objects on the page. Each object in the array contains properties such as question, correct_answer, and incorrect_answer. Moreover, I have implemented a state called disable which toggles between ...

How to Remove Carousel Arrows in Bootstrap 5

Any suggestions on how to remove the previous and next arrows in a Bootstrap carousel, particularly on the first and last slide? I'm struggling to find a solution for Bootstrap 5 as most solutions available are for older versions. Your help would be g ...

When setValue is called on VCheckbox in Vuetify, it emits an event called "update:modelValue"

After setting a value for the checkbox, I encountered a warning message: [Vue warn]: Component emitted event "update:modelValue" but it is neither declared in the emits option nor as an "onUpdate:modelValue" prop. Example.vue <script setup lang="t ...

Utilize jQuery to showcase images on your webpage

There seems to be an issue with image display - sometimes the selected image does not show up until clicked a second time. Using jQuery $('#morefiles').change(function (event) { if (!(/\.(gif|jpg|jpeg|tiff|png)$/i).test($(this).val())) { ...

Angular 2 does not have the capability to incorporate the Material library

Currently, I am exploring the Microsoft.AspNetCore.SpaTemplates sample of angular 2, where I installed the angular/material npm module in an attempt to integrate input material. UPDATE -- I have a new question about the elimination of server-side renderin ...