The Trainee: Identifying Items That Don't Belong

I have been tasked with creating a functional test for our custom Dropdown Control that includes a "readonly" feature. Initially, we planned to ensure that the dropdown list would not appear when clicked on, as it is typically expected behavior. The list does not actually exist in the DOM until it is rendered.

Here is the structure of the functional test:

'test case: can be interactive in read-only mode without opening the menu': function() {
    return this.remote
      .get(require.toUrl('/tests/dropdown/readonly'))
      .setFindTimeout(10)
      // Simulate click on the dropdown pseudo element
      .findById('readonly-dropdown-shdo')
        .click()
        .end()
      // try to locate the dropdown list (it should not be present since this is a "readonly" dropdown)
      .findById('dropdown-list')
        .then(function(element) {
          expect(element).to.be.empty;
        })
        .end()
      // Verify the currently active element (should be the psuedo-element)
      .getActiveElement()
        .getAttribute('id')
        .then(function(id) {
          expect(id).to.equal('readonly-dropdown-shdo');
        })
        .end();
},

The test fails at .findById('dropdown-list') due to a "NoSuchElement" exception thrown by Selenium, which is accurate because the element does not exist. The issue lies in Intern's test runner automatically marking these errors as failures, even though it aligns with the expected behavior.

My query: What is the recommended approach to validate the absence of an element on a page during a specific scenario?

Answer №1

For a different approach, consider utilizing findDisplayedById() as an alternative to findById() in this manner:

.findDisplayedById('dropdown-list')
        .then(...)
        .catch(...)
        .end()

Answer №2

Instead of focusing on what is missing, focus on what should actually be present - such as your pseudo-element.

(By the way, if I were in your position, I would suggest disabling the dropdown rather than rearranging elements. This approach would simplify testing and maintain semantic accuracy. Disabled dropdowns do not expand unnecessarily.)

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

Angular being called before being established

After spending a considerable amount of time working on AngularJS, I encountered an error stating that Angular is being used before it was defined. Despite watching several instructional videos and thoroughly reviewing the documentation, even with just the ...

Obtaining information from the internet

I've been working on this code snippet: from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager import pandas as pd driver_BV = webdriver.Chrome(service=Service(Chro ...

Issue with displaying jqplot in a jQuery page

Currently, I'm utilizing jqmobile pages for switching between various pages in an html5 application. One of these pages features a jqplot chart. Below is the code snippet: <div data-role="page" id="page-two" data-title="Page 2"> &l ...

Can chromedriver.exe version be checked during runtime using python?

In my current project, I am working on validating the compatibility between Chrome and Chromedriver to ensure that users download the correct version of Chromedriver if necessary. My goal is to find a method for checking the version of Chromedriver in a ...

Rotate Array Elements by N Spaces in JavaScript

Implement a function called "rotate" that will take an array and return a new array with the elements rotated by n spaces. If n is positive, the array should be rotated to the right. If n is negative, then it should be rotated to the left. If n is 0, the ...

The function to automatically refresh the page upon the user receiving a new message is currently malfunctioning

Having trouble with the page reloading when a new message is received by the user. I have been working on developing a PHP chat application that allows both admins and users to chat with each other. Whenever a new message is sent, the user has to manuall ...

Creating a query string in MongoDB using [Object] as a field

Currently, I am in the process of constructing a string within Meteor to delve deeper into my MongoDB data. The structure of my data can be seen here: Data In my JavaScript code for Meteor projects, I have formulated the string as shown below: const co ...

Strategies for correctly referencing and filling nested schema structures

TL;DR How can I reference and populate subdocuments within the same collection in Mongoose? I have been attempting to populate a reference to a subdocument in my Mongoose schema for some time now. My main schema (MainSchema) contains arrays of locations a ...

Having trouble accessing the length property of an undefined array while passing it from Node to Jade

Hey there! I'm currently working on rendering jade from node using the following code: router.get("/register", function (req, res) { var countries = [1, 2, 3]; res.render("./account/register", { countries: countries }); }); Below ...

What is the best way to implement a "param" feature similar to React's onChange and onClick methods?

I am interested in replicating the functionality of React's onClick, onChange, etc. An example of how React does this is: onClick={(event)=>console.log(event)} My goal is to achieve a similar effect using my custom property: someProp={(wanna_do_t ...

Ways to resolve the following C# problem: No match found for the specified testcase filter `FullyQualifiedName =`

As someone who is new to C# and Selenium, I have created several scripts successfully. However, I am encountering an issue when I try to create multiple methods or classes. Each time I stick to just one method or class, everything runs smoothly. I have sc ...

Initiate monitoring for child component modifications

I'm looking to disable 'changeDetection' for the parent component while enabling it for the child component. Can you provide an example of how this can be achieved? The parent component contains static data, meaning change detection is not ...

Is there a way to make a text area move along with the mouse cursor?

I have been working on my first website and everything is running smoothly so far. However, I have a new idea that I am struggling to implement. Some of the pages on my site feature a video player with buttons to select different videos. When a viewer hove ...

encountering issue alerts when using the MUI TextField module alongside the select function

Encountering an error in the MUI console: children must be provided when using the TextField component with select. <TextField select id="outlined-basic" label="User Name" name="user" size="small" {...teamForm.getFieldProps("user")} erro ...

Deciphering a Base64 image string in order to convert it back into a file for uploading to Parse

Incorporating CropperJS into a Node.js solution poses a challenge for me as I aim to convert the returned Base64 string into a file format in order to upload it. The goal is to maintain functionality while utilizing the file type as a parameter. Despite m ...

Establish a WebSocket connection via Meteor.js

How do we establish a Websockets connection in Meteor? Can we achieve this using the following code: ws = new WebSocket('ws://localhost/path'); ws.on('open', function() { ws.send('something'); }); ws.on('message&apo ...

Using Javascript to retrieve the childNode

I have encountered a challenge that I am struggling to overcome. My issue involves utilizing a dynamically generated table with 4 columns: a checkbox, text values, and a hidden input. echo "<tr><td><div class='input-containerh'> ...

Error in Node.js: Unable to access properties of null value within Express

While using Express (with node.js) and MongoDB, I encountered an error when trying to view or update a user profile. The middleware token check worked fine getProfileFields:::::::::::::>>>>e: TypeError: Cannot read properties of null (rea ...

Ways to verify the status within the DataTable?

Checking the condition inside column "data":"selectionAudit[0].assignFromDate" of a datatable to display content based on the conditions. var table4 = $('#auditAndNonAudit').DataTable({ "processing" : true, "scrollY": 100 ...

Tips for incorporating an outside model into vue.js with babylon js

Struggling with importing a gltf file into vue.js using babylon.js to create a 3D view on a webpage. The documentation online isn't very clear, and I've tried the following steps in my Hello.vue file: <div> <h1> Hello </h1> < ...