LeadFoot's intern framework encountered difficulty locating an element

I am currently in the process of writing functional test cases using the leadfoot intern framework. The specific test case I am working on involves entering text into a form field and clicking a button that triggers the opening of a bootstrap modal. My goal is to verify the display property of an element within this modal.

However, I am encountering an issue when trying to locate the element with the id 'viewBtn'. An error is thrown stating: NoSuchElement: [POST http://localhost:4444/wd/hub/session/e23a975b60188479d599d2 43505ce9cb/element/0.1521919297986265-4/element / {"using":"id","value":"viewBtn tBtn"}] no such element: Unable to locate element: {"method":"id","selector":"viewBtn "}

define(function (require){
    var registerSuite = require('intern!object');
    var assert = require('intern/chai!assert');

    registerSuite({
        name:'Test Page',
        'Continue':function(){
            return this.remote
             .get(require.toUrl('http://sdfsdfs'))
             .setFindTimeout(5000)
            .findById('to')
            .click()
            .type('john')
            .end()                      
            .findById('from')
            .click()
            .type('man')            
            .end()          
            .findById('message')
            .click()
            .type('hello')
            .end()          
            .findByCssSelector("[name=formName]").findByClassName('btn')
            .click()
            .end()
            .setFindTimeout(5000)
            .findById('viewBtn')
            .isDisplayed()
            .then(function(text){
                assert.equal(text,'true','Not Displayed');
            })
        }
    });
})

;

It's puzzling why the error is being triggered even though the specified id exists in the element. Additionally, I'm curious as to whether calling the end method after every find operation might be contributing to this issue?

Answer №1

It seems like the search context may need adjusting. In this code snippet, there is only one end between two find operations (findByCssSelector and findById). This indicates that the context for the findById('viewButton') call is within an element named "formName" (so the findById is searching within/under the element with name="formName"), as only the findByClassName call was terminated:

.findByCssSelector("[name=formName]").findByClassName('btn')
.click()
.end()
.setFindTimeout(5000)
.findById('viewButton')

If the intention is to search the entire document, you can use end(2) to end both find operations.

Additionally, keep in mind that setFindTimeout remains persistent, so it only needs to be called once unless the value is being changed.

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

Challenges encountered when attempting to access files from the filesystem on vercel

Currently, I am working on a website that includes a "blog" section with markdown files. The setup reads the files seamlessly from the file system without any errors... except when deployed on Vercel. In that case, it throws a "No such file or directory" e ...

Tips for storing a JavaScript variable or logging it to a file

Currently working with node, I have a script that requests data from an API and formats it into JSON required for dynamo. Each day generates around 23000 records which I am trying to save on my hard drive. Could someone advise me on how to save the conte ...

What is the best way to upload a canvas image from a GUI to the back-end using an AJAX call and setting the content-type as "image/jpeg"?

What is the best method for saving a canvas image from GUI to back-end using an AJAX call that accepts content type "image/jpeg" and avoids the error "jquery.js: 8453 Uncaught TypeError: Illegal invocation?" HTML <canvas id="myImage"></canvas> ...

A variable must be defined within a specific block in order to be recognized

In an effort to enhance my code within a passport function, I am looking to pull values from a mongodb Database rather than from an array. The initial functioning code appeared as follows: passport.use( new LocalStrategy( { usernameField: ...

Angular JS presents an exciting feature called Multiple Filters, which allows

I have a data representation application that displays information in table format with columns id, name, price, quantity The data is presented using ng-repeat. You can view it on this Plunker <body ng-controller="myController"> <h1>Data< ...

Navigating React Redux Pages Using React Router

At the moment, I am exploring the possibility of creating an application using React and Redux. Most examples I've come across make use of React Router, so I'm curious about its purpose. My application will consist of multiple pages (at least 20 ...

Java Selenium - encountering issues with the sendKeys() method

There is an issue with the sendKeys function in my code: The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String) Error line of code: driver.findElement(By.name("username")).sendKeys("Bharat& ...

Ways to eliminate a specific Chip from Autocomplete outside of material UI

Seeking assistance with displaying selected values as <Chip /> outside of the <TextField /> in <Autocomplete />. The issue lies in deleting these chips and updating the selected prop within <Autocomplete />. Any suggestions or solut ...

What is the process to create an adjacency multi-list in Java?

In my Java code, I am attempting to create a node/vertex based adjacency multi-list structure. Typically, these lists are edge based, but I am looking to display each vertex along with the edges connected to it. ...

How can I locate a single hidden field within a div containing multiple fields?

Within one div, I have three hidden fields. How can I access and retrieve just one of these hidden fields when referencing this specific div? ...

Using the ref callback to access getBoundingClientRect values in React Components

I'm having some trouble extracting data using the getBoundingClientRect() method from a set of animated div elements. The issue I'm facing is that the refCallback function is returning empty DOMRect objects. If you're interested, feel free t ...

What could be the culprit behind the error in the "blend-mode" function when using .mp4 files in Firefox?

Attempting to utilize mix-blend-mode with an mp4 playing in the background has been a fun experiment. The concept is to have a div containing some text, with the video playing in the background to create an effect on the letters. This method works flawless ...

"Enhancing User Interaction with AngularJS: Leveraging ng-click and ng

Currently, I have a map with markers that trigger an overlay-div to open when clicked. <div class="map" ng-init="loadall()"> <a ng-click="details.show=!details.show" href="#/dealer/{{marker.id}}" class="marker" style="left:{{marker ...

Guide to setting up CKeditor

I am struggling with the installation of CKEditor. After downloading the editor from the website, I inserted the code below between the head tags of my webpage: <script type="text/javascript" src="ckeditor/ckeditor.js"></script> <script typ ...

Utilizing onClick with material-ui button - functioning flawlessly for a single interaction

I have been attempting to encapsulate a Material-UI button within another component. Everything seems to be working well, except for when I try to handle the onClick event - it appears to only work once. Here is an example that demonstrates the issue: ht ...

Issue with React Hook Form - frequent failure in submitting the form

I have implemented the useForm hook from https://www.npmjs.com/package/react-hook-form. However, I am encountering some inconsistent behavior where it sometimes works immediately, sometimes requires a page refresh to work, and sometimes doesn't work a ...

JavaScript button is not functioning properly to increase or decrease the value in the input field

I'm facing an issue with the javascript increase/decrease buttons on my website. When I assign my JS variable as the class name of the input field, pressing the button results in all input fields being affected simultaneously: https://i.stack.imgur.c ...

Encountering a snag when trying to load JavaScript within an HTML document

I encountered an error while trying to load an HTML file in the JavaScript console of the Brave browser. The error message reads: require.js:5 Uncaught Error: Module name "constants.js" has not been loaded yet for context: _. Use require([]) https://requir ...

How to associate an object with a component in Angular2/TypeScript using HTTP

I am currently working on displaying a list of item names retrieved from a REST API. By utilizing the map function on the response observable and subscribing to it, I was able to obtain the parsed items object. Now, my challenge is how to bind this object ...

Error TS2322: Cannot assign type 'Promise<Hero | undefined>' to type 'Promise<Hero>'

I am currently studying angular4 using the angular tutorial. Here is a function to retrieve a hero from a service: @Injectable() export class HeroService { getHeroes(): Promise<Hero[]> { return new Promise(resolve => { // ...