What is the best way to find an element using either 'className1' or 'className2'?

Within my project, all locators are defined as elements of an enum and follow this format:

For example, if it is a CSS locator -

DIV_LOCATION("css=div.location-text.text-overflow")
. This method parses the string and identifies it as a CSS locator if it begins with css=.

Similarly, for an XPath locator -

DIV_HEADER_GRP_TITLE("//*[contains(@class,'conversation-title')]//div")

I am looking to create a universal CSS locator that can locate both of these elements:

<div class='conv-title'>...</div>
and
<div class='conversation-title'>...</div>

How can I achieve this?

The locator must start with css=

Answer №1

cssSelector either has or doesn't have ,

By.cssSelector(".conversation-title, .conv-title")

Answer №2

To style the input element mentioned above:

CSS code: input[class*="conv"]

This CSS selector will target any input element that has a class containing 'conv'

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

Encountering issues with styling the search bar using CSS and unable to see any changes reflected

I am currently working on creating a searchBar and customizing its CSS, but unfortunately, most of the styling properties seem to not be taking effect. So far, only changing colors seems to work as expected. .mainBar{ background-color: blue; width: ...

An issue occurred while attempting to read words from JSON file

My current issue involves loading words from JSON into my webpage. The images are functioning properly, thankfully. I have already successfully loaded the necessary images through JSON onto my webpage. However, I am still in need of loading words through ...

What is the best way to have an image fill the remaining space within a 100vh container automatically?

I have a container with a height of 100vh. Inside it, there is an image and some text. The text's height may vary based on the screen size and content length. I want the text to occupy its required space while the image fills up the remaining availabl ...

Enhancing the Search Form Minimum Width in Bootstrap 4 Navbar

Looking for a way to create a search form with a width of 100% and a minimum width within a Bootstrap 4 navbar? Check out my code snippet here. <nav class="navbar navbar-expand-md navbar-light bg-faded"> <a href="/" class="navbar-brand">Brand& ...

Display overlay objects specifically focused around the mouse cursor, regardless of its position on the screen

I am currently working on a project using SVG files and processing.js to develop a unique homepage that incorporates both animation and static elements. The concept is to maintain the overall structure of the original homepage but with varying colors, esse ...

Is it possible to create a versatile function that can interact with both mobile and web elements interchangeably?

public static < T > void clickOnElement( T element ) { } I am attempting to create a universal function that can accept different types of elements, such as WebElement for Selenium and MobileElement for Appium, in order to execute a click event ...

Tips for concealing the check mark within a checkbox upon selection

I have checkboxes arranged in a table with 23 columns and 7 rows. My goal is to style the checkboxes in a way that hides the check mark when selected. I also want to change the background image of the checkbox to fill it with color when marked. Can someone ...

Cover the entire screen with a solid background color and adjust the text size accordingly

I'm encountering two issues. Despite my efforts to adjust multiple containers, the background colour #eee simply won't reach the bottom of the screen. I've even tried setting the HTML height to 100%, but to no avail. Even though I&apos ...

Experiencing issues with a malfunctioning Chrome extension? The CaptureVisibleTab feature seems to be failing when using

Whenever I try to use the captureVisibleTab function on a page where I have a div with preserve3d in CSS3, all I see is a blank page. How can I solve this issue? Here is my simple code for capturing the browser screen: chrome.browserAction.onClicked.addL ...

How to use Selenium with Python to verify a checkbox is not selected

I am encountering the following Page Source: 1. <li_ngcontent-shv-c123 mat-menu-item role="presentation" class="mat-focus-indicator dropdown-item mat-menu-item ng-star-inserted" tabindex="0" aria-disabled="false"& ...

Having trouble with your jQuery slideDown menu?

I am facing the exact same issue I had last week. Here is an example of my HTML code: <article class="tickets"> <div class="grid_12 left"> <div class="header"> <i class="ico ...

A Simple Java Method to Locate Elements

I am curious about how to convert these 2 generic methods for Selenium in C# into a Java version, as I do not have any experience with Java: public static IWebElement ConvertMethodForJava(Func<IWebDriver, IWebElement> expectedCondtions, int timeou ...

Showing a pop-up on a click of a dynamically created table row, showcasing information specific to that row

I am facing a challenge with my dynamically generated table that is based on the JSON response from an AJAX call. What I am trying to achieve is to display additional data in a modal when a table row is clicked. This would be simple if the data was hard co ...

Python (selenium) login attempt failure - finding success with v-on:click="submitForm"?

Is Selenium the right module to use for clicking this type of button, or should I be using a different one? Can you provide the related code as well? Any help would be greatly appreciated. Thank you in advance. I'm new to coding and currently learnin ...

Understanding the Contrasts of @By and @FindBy in Page Object Model with Selenium

Seeking assistance to understand the distinction between @By and @Findby when implementing Selenium with Page Object Model. Can anyone shed some light on this? ...

Encountering overlap issues when applying labels to my flexbox using the Spectre framework in CSS

I need help creating a "hat" with two textarea columns using the spectre.css framework. My goal is to have these columns resize based on the screen size, stacking on top of each other when the screen size is below 600px. I can achieve this without any issu ...

I am struggling to remove the div from its normal flow as it stubbornly remains positioned below

Is there a way to add a "contact" card to my website's right-top corner in a sticky position? I currently have a div block in that area which is blocking the contact card. Can anyone suggest a solution for this? https://i.stack.imgur.com/umC7B.jpg &l ...

How to instantly return progress bar to zero in bootstrap without any animations

I am currently working on a task that involves multiple actions, and I have implemented a bootstrap progress bar to visually represent the progress of each action. However, after completion of an action, the progress bar is reset to zero using the followi ...

Creating a div that spans the entire height from top to bottom

Currently, I am faced with the following scenario: <div id=area> <div id=box> </div> </div> <div id=footer> </div> The "area" div is situated in the center and has a width of 700px with shadows on both the right and ...

Resolved navigation bar problems

As a beginner in web development, I am working hard to launch my first website. Today, I have a question for the stack overflow community regarding a fixed navbar issue. The navbar I have created is functioning properly on Chrome, but when it comes to Fire ...