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

Even after assigning the class "img-fluid" to my image, it still fails to properly adjust to the screen size

I added the class "img-fluid" to my image in Bootstrap, but it's not fitting on my webpage. What should I do? <img src="images\406201.jpg" class="img-fluid" alt="..."> <div style="margin-top: 0p ...

What is the best way to display the weather information for specific coordinates in ReactJS?

I've been working on a code that retrieves farm details based on longitude and latitude. My goal now is to fetch the weather information for that specific farm using openweathermap However, each time I attempt to do so, an error message {cod: '4 ...

Enhance your loader functionality by dynamically updating ng-repeat using ng-if

To better illustrate my issue, here is a link to the fiddle I created: https://jsfiddle.net/860Ltbva/5/ The goal is to show a loading message while the ng-repeat loop is still loading and hide it once all elements have been loaded. I referenced this help ...

Ways to transmit data multiple times within a single request

I'm currently developing an app using Nodejs and express, where orders can be placed for specific products. In this application, when an order is received, it is saved in the database and a PDF receipt is generated immediately. However, since generati ...

How can you organize an array into rows and columns for easier viewing?

Hopefully everything is clear. I am open to making changes if needed to address any important points. In one of my components, the array items are displayed within cards as shown below: <b-card-group deck class="mb-3"> <b-card border-variant ...

The Bootstrap Navbar is causing the navigation bar to span across two lines

I'm having an issue with my navbar taking up two lines on desktop resolution, but fitting perfectly on mobile. I've spent hours going through the code with no success. Any help would be greatly appreciated. The HTML code is provided below. <! ...

User information in the realm of website creation

Can someone provide insight on where user data such as photos, videos, and posts is stored? I doubt it is saved in an SQL database or any similar system. ...

React does not allow objects as child elements. Instead, render a collection of children by using an array

Encountering an error with this React class Error: Objects are not valid as a React child (found: object with keys {_id, name}). If you meant to render a collection of children, use an array instead. Is there anything amiss here? I am passing the movies ...

Is it possible to modify the appearance of the element that was just clicked on?

Hello everyone, I'm currently working on a form with different inputs, all with the same class: <input type="text" name="username" class="field" /> <input type="text" name="email" class="field" /> I'm trying to figure out how to ch ...

define a variable within a v-for loop

Example of Code <div v-for="item in dataItems"> <div v-if="enableEdit"> <input type="text" v-model="name"> </div> <div v-else> {{name}} </div> <button @click="enableEdit = true">click</button> This ...

Modify the database once authorized by the administrator

`I have a webpage that showcases testimonials. I am looking to only display the testimonials with a "status" of "1" in my database. How can I quickly update the "status" column from "0" to "1" right after the admin clicks on update? I am also incorporati ...

Disabling the Autocomplete Drop-Down Arrow

Can the drop-down arrow icon be removed from the material-ui Autocomplete react component? My current view includes a blue arrow that I'd like to remove, opting instead for text to automatically drop down as I type. https://i.stack.imgur.com/ZTLYu.p ...

Unable to utilize Socket.io version 2.0.3

When it comes to developing a video chat app, I decided to utilize socket.io. In order to familiarize myself with this library, I followed various tutorials, but unfortunately, I always encountered the same issue. Every time I attempted to invoke the libr ...

Updating the Bootstrap entry dynamically within the @NgModule module

My web application has a specific requirement where it can only be accessed through example.com/index.html without any parameters. The backstory behind this restriction is quite lengthy, so let's not delve into that. Within the index.html file, I have ...

Using optional arguments in my AngularJS controller.js

In my controller.js file for AngularJS, I have the following code snippet: app.controller('MetaDetailGroupList', ['$scope', '$http', function($scope, $http) { $http.get(Routing.generate('meta-detail-group-list&ap ...

Prevent users from copying and pasting text or right-clicking on the website

I have been struggling to completely disable the ability for users to copy and paste or select text on my website across all devices. After much searching, I came across a solution that I implemented on my site. Below the <body> tag, I inserted the ...

Using Vue for Firestore pagination

Utilizing the bootstrap-vue pagination component: <b-pagination v-model="currentPage" :total-rows="rows" :per-page="perPage" ></b-pagination> Component.vue: export default class PaginatedLinks extends Vue { public currentPage: number ...

Issue with Dropdown Menu functionality while using multiple dropdown options

I am currently experimenting with dropdown menus from W3Schools and have encountered an issue when trying to implement two dropdown options. The code works fine for a single dropdown, but when I try to add a second one using GetElementsByClassName instead ...

Validating Forms using Javascript

I'm struggling to understand why I'm not getting any error or success messages when I click the submit button. My goal is to validate strings in an HTML form to ensure they are not null or too long. Both the developer's tools and the Online ...

Which style is more legible when conditionally rendering a multitude of components?

Imagine a scenario where there's a web application page with a data table that can be edited based on certain permissions. In this case, the editing capabilities are limited to selecting and deleting rows. Which approach do you find more clear for th ...