Is there a way to verify the presence of a specific word within a classname?

My goal is to verify if the string ("Pre laminated ") matches the css class name I am checking.

I only need confirmation of whether the given word is present in the classname: Output "pass" if it exists, output "fail" if it does not.

Answer №1

It appears that you're referring to CSS classes, in which case here is the solution:

WebElement targetElement = ...;
String classValue = targetElement.getAttribute("class");
if (classValue.contains("Pre laminated")) {
    LOGGER.log("success");
} else {
    LOGGER.log("failure");
}

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

What could be causing my links to not appear in Internet Explorer 9?

Why are my links not showing up properly in Internet Explorer 9? If you prefer not to visit the website, you can directly access the style sheet at... This issue is specific to IE 9 and does not occur in other versions of Internet Explorer. ...

Comparing Selenium to the Prestigious New York Metropolitan Opera

Hello everyone, I am new here and this is my first question. Please bear with me as I navigate through. I am facing challenges with scraping javascript generated pages, specifically the schedule of the Metropolitan Opera. My goal is to create a calendar f ...

Is the JavaScript progress bar dysfunctional when used with object-oriented JavaScript code, but functions properly with arrow functions?

After posting a question about the JavaScript progress bar not working with object-oriented JavaScript code on Stack Overflow, I decided to try rewriting the script using arrow functions. Here is the new code: document.getElementById("barButton").addEve ...

Unable to modify the bar's color using the .css document

Below is the JavaScript code being used: var marginEducation = {top: 20, right: 30, bottom: 40, left: 300}, widthEducation = 1000, heightEducation = 460; const svgEducation = d3.select("#Education") .append("svg") .attr("w ...

Python Selenium - href Attribute yields incorrect hyperlink

Currently, I am utilizing Selenium to extract href elements within div class elements from comments on Facebook posts. To achieve this, I am using https://m. instead of https://www. The strange issue is that the code is functional but it generates an inc ...

jQuery will envelop the HTML elements in an inconsequential div

Imagine a website that is visually complex, with various styles and images positioned in different ways. What if we wanted to add a small overlay icon above each image? At first, the solution might seem simple - just use absolute positioning for a span el ...

What is the significance of using em units in web design?

As I delve into an older project that heavily relies on em's for all design elements, including font sizes and layouts, I can't help but question the benefits of using em's in this way. Do they truly offer any advantages when it comes to lay ...

"Seamless connectivity: Bridging the gap between HP ALM and

Can a connection be made between HP ALM and Appium to automate test execution in ALM? ...

Ways to halt the loading of a webpage on Firefox using code

Currently, I am carrying out various tests using WebDriver and Firefox. I have encountered an issue with the following command: WebDriver.get(www.google.com); When this command is executed, WebDriver waits for the onload event to be triggered. While thi ...

I'm seeking a way to access the input element within the InputGroup component of BlueprintJs in my

The BluePrintJS React InputGroup component offers a convenient user interface for modern applications. However, it does not provide direct access to the internal <input> element. There are two primary reasons why I need to access the input element: ...

Another element is blocking the clickable element from being accessed

Here is a simple function: def twoclicks(idoutter,idinner): wait = WebDriverWait(driver, 20) wait.until(EC.element_to_be_clickable((By.XPATH, "//input[contains(@id," + idoutter + ") and @value='...']"))).click() sleep(5) wait.unt ...

The Jquery animate function is not compatible with the transform property

I am facing an issue with the Jquery animate function. Despite trying various solutions, I have been unable to get it to work. Below is the HTML code that I have used: <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

Applying CSS to select a different element style within a webpage

I was thinking about the possibility of linking one style to another using events like :focus or :hover in CSS alone, without the need for JavaScript. For instance, can the class "hitArea" change the background attribute of "changeArea" when it is in foc ...

Preview not showing CSS changes properly

1) I am encountering an issue with displaying CSS in a form preview tab. Despite setting the CSS, it does not reflect on the fields after clicking the preview button. 2) Are there alternative methods to open the tab in a new window rather than opening it ...

Unveiling Elements as You Scroll Within a Specified Area

I have implemented a jQuery and CSS code to reveal my contact form as I scroll down the page. However, I am facing an issue with setting a specific range for displaying the element while scrolling. Currently, I have only managed to handle the scrolling dow ...

Tips for creating a Selenium WebDriver script to automate login functionality on a specified webpage referenced in the provided link

<a class="login" data-toggle="modal" href="/login/">Log in</a> The snippet of code above is designated for the log-in functionality when clicking on a specified icon. It pertains to accessing the log-in page of a particular website. Unfortunat ...

To run Selenium on a Raspberry Pi, the required Chrome version should be at least 62 or higher

Attempting to execute a python selenium script on my Raspberry Pi using the selenium package resulted in an error upon running the script: browser = webdriver.Chrome(executable_path=chr, chrome_options=options) [...] selenium.common.exceptions.SessionNotCr ...

Automating website navigation using dynamic waiting with Selenium and Scrapy

Recently, I successfully developed a web scraper using Python and Selenium. Initially, I relied on fixed time-outs to load the page while making use of Ajax calls to retrieve data. However, I discovered that Selenium offers a built-in function called WebDr ...

I want to use flexbox to center three divs on my webpage

I am trying to align 3 divs inside a flex container in the center of the page with equal distance between them and also from the edge of the page. .container { display : flex; width : 60%; } .para { width : 33%; padding : 1em; borde ...

Troubles with the placement of the navbar icon in responsive design

After following a tutorial on responsive navigation bars (https://www.w3schools.com/howto/howto_js_topnav_responsive.asp), I successfully implemented the navbar on my website. However, I encountered an issue with the icon placement when clicked. Here is ho ...