Emphasize SELENIDE rows

My goal is to achieve the following:

@Test
    public void tableTest() {
        getDriver().get(BASE_URL + "tabulka.php");
        List<WebElement> rows = getDriver().findElements(By.xpath("//table//tbody//tr"));

        for (WebElement row : rows) {
            if (row.getText().contains("Florian")){
                ((JavascriptExecutor) getDriver()).executeScript("arguments[0].style.border='3px solid red'", row);
            }
        }
    }

view image here

Now, I am attempting to accomplish this in Selenide

Selenide

   @Test
    public void tableTestAi() {
       ElementsCollection rows = $$("#table tbody tr");
        
        for (SelenideElement row : rows) {
            `if (row.getText().contains("Florian")){

                row.shouldHave(Condition.attribute("style", "border: 3px solid red;"));
            }
        }
    }

The test passes but nothing happens as expected

Here is a highLight test example:

    @Test
    public void itShouldHaveFloriannm() {
        ElementsCollection rows = $$("#table tbody tr");
        $x("//table//td[text()='Florian']").scrollTo().highlight();

        for (SelenideElement row : rows) {
            if (row.getText().contains("Florian")){
                row.scrollTo().highlight();
            }
        }
    }

However, only the first instance of Florian gets highlighted

@Test
     public void testFloriangg() {
        $x("//table//td[text()='Florian']").highlight()
                .findAll(By.xpath("//table//td[text()='Florian']"));
     }   

In this case, all occurrences are not getting highlighted. I am using Selenide version 7.2.1 Selenium version 4.18.1 JDK 21

Answer №1

To emphasize everything, it needs to be

@Test
 public void testHighlightFlorian() {
    $$("//table//td[text()='Florian']").forEach(element -> element.highlight());
 }   

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

Node.js encountering an empty array from an API request

In the 'product.js' file, there seems to be an issue with the API call '/achaar/products/1'. The value of val is empty when logging it in the console. Other API calls like '/achaar/products' are functioning correctly, but spec ...

Using AJAX to send data from knockout observables to the server in JSON format

I'm currently facing an issue where I am trying to send form fields that are linked to specific observables to my server as a JSON object, but I keep receiving an empty JSON string on the server side. I want to avoid sending the entire view model just ...

Include image hover text without using HTML

I am looking to add a hover effect to some images using CSS and JS since I cannot directly edit the HTML file. The goal is to have centered text pop out when hovering over certain images. I know the div class of the image but unfortunately, I cannot add te ...

Retrieve data from a single PHP page and display it on another page

In my project, I am working with three PHP pages: index.php, fetch_data.php, and product_detail.php. The layout of my index.php consists of three columns: filter options, products panel, and detailed description. Whenever a user clicks on a product in th ...

Exploring the depths of Rx.ReplaySubject: Techniques for delaying the `next()` event

Confused Mind: Either I'm mistaken, or the whiskey is starting to take effect. (I can't rule out the possibility that I'm just going crazy. Apologies for that.) Assumption: My assumption was that ReplaySubject would emit a single value eve ...

When attempting to load a page in Mozilla, the initial DIV code fails to load

When trying to load a page in Mozilla, the first DIV code is not loading. I attempted to load HTML inside using: <div id="mainContent"></div> with the following call: if (destinationURL != null) { $.get(destinationURL, function(data) { ...

Guide on updating property or field names within a personalized JSON serializer

I have created a custom serializer for a specific field. public class SearchSerialize extends StdSerializer<Value> { public SearchSerialize() { super(Value.class); } @Override public void serialize(Value value, JsonGenerator jsonGenerator, Seri ...

AngularJS function orderBy reverses the array instead of sorting it

I encountered an issue where, after clicking the 'order button', the table does not order as expected. Instead, it reverses all the td elements. For example, 'A', 'C', 'B' becomes 'B', 'C', "A". I ...

The callback function for ajax completion fails to execute

My current framework of choice is Django. I find myself faced with the following code snippet: var done_cancel_order = function(res, status) { alert("xpto"); }; var cancel_order = function() { data = {}; var args = { type:"GET", url:"/exch ...

Utilizing Boolean Operators in JavaScript with Thymeleaf: A Guide

When incorporating Boolean conditions in JavaScript with Thymeleaf using th:inline="javascript", an exception is thrown which appears as follows: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 22; The entity name must immediately follow the ...

How can you disable a single button when clicked using the map method, and update the className after a timer runs out in React?

Is there a way to disable only one button when clicked using the map method? I currently have a disabled hook that affects all pressed buttons. Also, how can I revert the 'current__events__hot-price disabled' className back to 'current__even ...

Is there a way to monitor and trigger a function in jQuery when a loaded PHP file is modified?

I am currently working on a dynamic dashboard that automatically updates every few seconds to display new information fetched from a PHP file. My goal is to trigger an alert only when there is a change in the data itself, rather than just a refresh. In ord ...

JavaScript-powered dynamic dropdown form

I need help creating a dynamic drop-down form using JavaScript. The idea is to allow users to select the type of question they want to ask and then provide the necessary information based on their selection. For example, if they choose "Multiple Choice", t ...

JSON to Table Conversion

On the hunt for a php script that can load CSV files? Look no further than this snippet: echo json_encode(file(csvfile.csv, FILE_IGNORE_NEW_LINES)); Check out the output: ["foo,bar,baz","foo, foo,bar","bla,bla,blubb"] Need to integrate this into your ...

I could really use some assistance with this project for my friend

Whenever I click on the image, it only displays two out of the three possible alerts. How can I make it show all three? Here's my code: <!DOCTYPE html> <html> <head> </head> <body> <img src="http://www.build ...

Issue encountered while attempting to download the most recent version of chromedriver

Currently, I am using Chrome version 115.0.5790.110 and Selenium version 4.10.0. Below is my Python code snippet: from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager ...

At times, the map may only be visible in the top left corner of its designated container

Currently, I am integrating the Google Maps API v3 for JavaScript into my project. However, I am facing an issue where the map only appears in the upper left corner under certain circumstances. To visualize this problem, you can visit this link and click ...

Code displayed on Facebook when sharing a website link implemented in JavaScript

Is there a way to prevent javascript code from appearing in Facebook posts when sharing links, whether it's done manually or through programming? I'm specifically looking for solutions to fix my website so that when I post links on Facebook, the ...

Confusion arises from conflicting Vue component script indentation guidelines

As I work on setting ESLint rules for my new Vue project, I am extending both eslint-plugin-vue and airbnb. All is well except for one issue - the indentation of the tag inside Vue components. The usual accepted format looks like this: <script> ex ...

What is the best way to send a JSON object to bootstrap-table?

In my controller, I am passing a JSON encoded object to the view. Using a Bootstrap table in the view to display the data, but it is showing "No matching records found." Can someone please assist with this issue? Here is my controller: see image And here ...