Ways to choose an element when all classes are identical but the text content varies?

I'm looking to automate the website, specifically by selecting the Widgets section and clicking on it. The issue is that all the cards have the same class name, only the text inside them differs. I tried using this code snippet:

get getWidgetButton() { return $('//h5[normalize-space(text()) = "Widgets"]'); 
But when I execute this command
When('user press on Widgets button', ()=>{NavigationPage.getWidgetButton.click(); });
an error occurs.

  1. Widget Data Picker When user press on Widgets button [chrome 87.0.4280.88 windows #0-0] element click intercepted: Element ... is not clickable at point (709, 669). Other element would receive the click: ...

How can I successfully select the desired element? Thank you!

Answer №1

There are various methods to accomplish this task, such as extracting the innerText from an HTML element or selecting the nth-child using querySelector

Answer №2

When attempting to interact with elements on a webpage using WebdriverIO, try utilizing the element.waitForClickable() method first. This can help ensure that the element is ready for interaction without requiring manual scrolling.

WebdriverIO offers simplified selectors, with the ability to primarily use CSS selectors. There are two main ways to select elements:

  1. If you need to select multiple elements with the same className in WebdriverIO, you can use $$ to return an array of elements. By specifying the index number, you can access specific elements. For example, to select all headers within widgets:

    get widgetHeaders () { return $$('.card h5') }
    . If the Widget card is the 4th element (index 3), you can click on it using widgetHeaders[3].click();. More information available at: findElements in WebdriverIO

  2. To find a single element based on inner text, you can use queries like

    get getWidgetButton() { return $('h5=\'Widgets\']');
    . Alternatively, to locate the first h5 containing 'widget':
    get getWidgetButton() { return $('h5*=\'Widgets\']');
    . Further details can be found here: findElement by inner text or by partial text

It's important for QA professionals to prioritize finding defects. In the shared website, there seems to be an issue with the footer overlapping the body content by 60px. This should be reported and addressed by the developers. A potential fix could involve adjusting the body height and padding, such as:

.body-height { min-height: 100%; padding-bottom: 70px; }

Answer №3

It appears that the issue you are facing is due to your browser window being too small, causing the "Widgets" button to be obscured by the page footer. To resolve this, try maximizing your browser window or using the option to start the browser in a maximized size.

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

redux reducer returns an empty array after applying filter to the state

In my React component, I am utilizing Redux to manage the state. Since I am new to Redux, I have encountered some challenges with one of the reducers I created. One of the methods in my component involves making an HTTP request and then dispatching the dat ...

Tips on dividing and recycling mongodb connection in Node.js

I am currently troubleshooting the connection to MongoDB using Node.js. The code I have in a file named mongodb.js is as follows: const mongoClient = require('mongodb').MongoClient; const env = process.env.NODE_ENV || 'development'; co ...

Ensuring payload integrity using microrouter: A step-by-step guide

I have utilized this code to develop a microservice const { json, send } = require('micro') const { router, post } = require('microrouter') const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY) console.log(process.e ...

What is the process of exporting a module that has been imported in ES6?

Here are 3 code snippets: // ./src/index.ts const myApp = { test: 1, ... } export default myApp // ./src/app.ts import myApp from './src/index' export default myApp // ./index.vue import { example } from './src/app.ts' console.l ...

Validating Angular UI without requiring an input field (validating an expression)

Currently, I am utilizing ui-validate utilities available at https://github.com/angular-ui/ui-validate The issue I am facing involves validating an expression on a form without an input field. To illustrate, consider the following object: $scope.item = ...

Angular is unable to detect the dynamically loaded page when using Extjs

Within my Extjs SPA system, I have integrated Angular along with the necessary modules to be used on a page that is being referred in an external HTML panel in Extjs. While Angular is defined and functioning properly everywhere else, it seems to not work ...

What is the process for configuring sendmail in a node.js environment?

After setting up Sendmail on my Nginx server and configuring SMTP for sending emails in my Node.js project, I still encountered issues with emails not being sent. I tried using Sendmail directly, but I'm unsure of how to properly configure it. Here i ...

Incorporating JavaScript/JSON into your Ebay listings to seamlessly receive user-selected choices

There has been a trend among Ebay users to incorporate dynamic data fetching and sending from external sources in their listings. This could be for implementing a shipping calculator or offering different product variants through dropdown lists. You can c ...

The current state of my DOM doesn't match the updated value in my model. The update is triggered by a function that is called when a button is clicked

app.controller('thumbnailController', function ($scope) { debugger $scope.customers = [ { name: 'Ave Jones', city: 'Phoenix' }, { name: 'Amie Riley', city: 'Phoenix&ap ...

Modifying the order of Vuetify CSS in webpack build process

While developing a web app using Vue (3.1.3) and Vuetify (1.3.8), everything appeared to be working fine initially. However, when I proceeded with the production build, I noticed that Vue was somehow changing the order of CSS. The issue specifically revol ...

Encountering an error while attempting to load the jQuery script: TypeError - $.fn.appear.run is not a

I have included an animation script for CSS in my markup, but I am encountering the following error: TypeError: $.fn.appear.run is not a function Does anyone know why this is happening and how I can resolve it? /* * CSS3 Animate it * Copyright (c) 2 ...

An error occurred as the Serverless Function timed out while attempting to load a dynamic route in Next.js version 13

I have a basic Next.js application with the following route structure: /contentA/ - Static - Initial load: 103 kB /contentA/[paramA]/groups - SSG - Initial load: 120 kB /contentB/[paramA]/[paramB]/[paramC] - SSR (client component) - Initial load: 103 kB ...

Understanding the scope within a .when .done function in jQuery

I'm currently grappling with accessing a variable from within a .when.done function. Take a look at this illustrative example: var colviews = { 1: true, 2: true, 3: false } $.when( $.getScript( "/mckinney_images/jquery.tablesorter. ...

The initial rendering of the connected component is unsuccessful due to the fact that the Redux state has not been fully

Currently, I am utilizing Redux thunk and axios to handle server requests and update the state based on the response. An issue arises when trying to render a connected component with an initial state that relies on data from the server. In this scenario, ...

Error encountered in Next.js Webviewer during build process: "Reference Error - window is not defined"

Currently, I am in the process of developing a website that includes a PDF viewer within a dynamically imported page. When I run the code locally, everything works without any issues. However, when I execute the "npm run build" command, I encounter the fol ...

Does adding the Angular bootstrap script at the end of the body tag impact webpage speed more than using ng-app on the body tag?

In the past, we had placed ng-app on the body tag which led to problems with dependency injection when multiple modules were being used on the same webpage. This required module creators to be aware of the existing app and inject their app into it. We are ...

In JavaScript, what do we call the paradigm where a variable equals a variable equals a function? Let's take

Feeling a bit overloaded at the moment, so forgive me if this question seems too simple. I managed to accidentally write some code in Jest for testing a Vue application that actually works: const updateMethod = wrapper.vm.updateMethod = jest.fn() expect(u ...

jQuery droppable: Encounter of an unexpected TypeError: undefined lacks the characteristics of a function

I'm trying to implement drag and drop functionality on my website. However, I am encountering an error message in the console that says: Uncaught TypeError: undefined is not a function ... presentation-categories.js?version=1:23. The error occurs at ...

Exploring the Possibilities: Incorporating xlsx Files in Angular 5

Is there a way to read just the first three records from an xlsx file without causing the browser to crash? I need assistance with finding a solution that allows me to achieve this without storing all the data in memory during the parsing process. P.S: I ...

Creating a Vertical Navbar Dropdown in Bootstrap 3.0 Without Appending to the Last List Item Only

Currently, I'm in the process of creating a panel layout that features an elegant vertical navbar. Although everything seems to be aligned correctly and I've managed to implement a dropdown menu in a vertical layout, it keeps appending to the las ...