Using Selenium IDE to verify the contents within <TD> elements that include a combination of tags and line breaks

I am currently working on verifying the contents of a complex TD cell, which includes a SPAN tag and multiple BR tags. My testing is limited to using Selenium IDE for this task. The HTML source code in question looks like this:

<td>
 <span><b style="whatever">TEXT_1</b></span> 
 <br style="whatever">
  TEXT_2
 <br style="whatever">
  TEXT_3
 <br>
</td>

It's important to note that TEXT_1, TEXT_2, and TEXT_3 do not contain any spaces.

To tackle this, I retrieve the TD cell contents into a variable named 'td_cell_contents'. Then, I use Javascript to split this variable based on a single space:

store | javascript{storedVars['td_cell_contents'].split(' ')[0]} | var_1
store | javascript{storedVars['td_cell_contents'].split(' ')[1]} | var_2

As expected, var_1 correctly evaluates to "TEXT_1" due to the presence of a space separating it from the rest of the cell. However, when I check var_2, the log output displays a new line between "TEXT_2" and "TEXT_3" because of the BR tag used:

[info] echo: var_2: TEXT 2
TEXT 3

Attempting to remove these new lines using JavaScript did not yield the desired result:

runScript | var_2 = var_2.replace(/(?:\r\n|\r|\n)/g, '<br />'); |

Subsequent echoes of var_2 still show the presence of the unwanted newline, hindering string matching capability.

I am seeking assistance and exploring alternative methods within Selenium IDE to verify the cell contents effectively, even if the newlines cannot be removed.

Answer №1

Based on my interpretation, it seems like you are aiming to verify the contents of var_2. Removing the newline character is one way to achieve this objective, although there are alternative methods available.

Have you considered creating a new variable named "expected_var_2_value" and assigning it the expected var_2 string without removing the newline? You can do so using the following code snippet:

store | TEXT_2\nTEXT_3 | expected_var_2_value

Then, you can compare it with var_2 using the following code:

verifyEval | storedVars['expected_var_2_value'] == storedVars['var_2'] | true

In my experience, using JavaScript in the verifyEval command works when comparing storedVars['expected_var_2_value'], but encounters issues when directly providing the original string.

I would love to hear your feedback on how this approach works for you.

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

Conceal and reveal elements using v-if

Check out my fiddle: DEMO creating a new Vue instance: { el: '#app', data: { modules: ['abc', 'def'] } } I am looking for a way to hide or show elements using v-if based on the values in an array called modules[]. ...

Missing Personal toolbar button on Forge Viewer interface

After completing the tutorial for learning Autodesk Forge, I successfully linked my BIM 360 account to the Forge Viewer. My next goal is to add extensions and have a button on the toolbar that directs to these extensions. However, when following the exten ...

rearranging items within a box with CSS

I am facing a challenge with the project I am currently working on. I have a group of buttons inside a container, and every time I attempt to adjust their position using CSS, the buttons end up disappearing. Additionally, setting a relative top or right va ...

Creating a custom JavaScript plugin that can be easily embedded using React and Webpack

I aim to bundle my React application with Webpack so that when placed on a CDN, it can be easily accessed, called, and initialized with specific client configurations. After going through this tutorial and this thread, I am structuring my webpack entry fi ...

Tips for solving the problem of page navigation using jquery-mobile

I have a jquery-mobile application with two actual HTML pages, but many more data-role="page" divs. The issue arises when transitioning from the first actual HTML page to the next one as the navigation stops working. I am not using any custom JavaScript, j ...

Modifying the hidden input value using JQuery

When using jQuery to change the input type hidden with dynamically appended buttons in the DOM, the code appears as follows: $("body").on('click', '.companyContractButt', function(){ var id = $(this).attr('data-id'); ...

Ways to resolve axios promise

My current task involves working on a GET request from an API. Upon receiving the response shown in the image, I noticed that the data presented in the promise is accurate. My goal is to display the letters and their corresponding promise data within the H ...

Is it possible for a d3 chart to render twice in one area if it's rendered in two different places?

When attempting to showcase two distinct d3 pie charts on my webpage within individual mat-cards, they both end up displaying in the svg tag of the first d3 chart in my code. This is what my code looks like: <section class="three"> <! ...

Exploring the power of Nestjs EventEmitter Module in combination with Serverless functions through the implementation of Async

I am working on implementing an asynchronous worker using a serverless lambda function with the assistance of the nestjs EventEmitter module. The handler is being triggered when an event is emitted, but the function closes before the async/await call. I ...

Build an upvote feature using PHP and WordPress that allows users to vote without causing a page reload

Just starting out as a developer and currently working on a website using WordPress. I want to implement an upvote button that allows users to upvote a post without the page needing to refresh. I understand that I'll need to use JavaScript to highligh ...

ignoring goog:chromeOptions completely while using RSpec, Capybara, and Selenium

Has anyone encountered this issue before? It seems like there may be an error in passing the goog:chromeOptions to chromedriver, causing Chrome to open with default settings. My Capybara/Selenium configuration is as follows: Capybara.register_driver :chr ...

There was an issue stating that valLists is not defined when paginating table rows with AngularJS and AJAX

I found a helpful code snippet on this website for implementing pagination in AngularJS. I'm trying to adapt it to work with data from a MySQL DB table called 'user', but I keep running into an issue where the valLists variable is undefined, ...

Select2 - Ajax Selection Fails to Render Item

Utilizing a Select2 Object for an ajax data source, the following HTML is used: <select class="form-control" id="customerSelect" style="width: 200px !important;"></select> The JavaScript code below initializes and ...

Is it possible to create and execute scripts in Selenium WebDriver without requiring JDK installation?

As someone who is just starting with selenium webdriver, my team is currently developing a proof of concept for automation testing using Selenium. I am curious to know if it's possible to write and execute selenium webdriver test cases in Java without ...

Creating a dynamic search bar animation using jQuery's animate function

Check out the live demo I'm working on animating a search form. Currently, it slides from left to right, but I want it to slide from right to left instead. Additionally, I would like to add a smooth easing effect to the animation. Here is the HTML c ...

I created some jQuery code that modifies a button when it is hovered over, however, I ended up writing the code individually for each button. What steps can I take to turn it

Is there a way to turn the code for each button on my website into a jQuery function that can be applied to any button? This is how the code currently appears: $(document).ready(function() { $("#linkXML").hover( function() { ...

Creating a personalized pathway for accessing a user's settings

Oops! Looks like there's an error: An element is only ever to be used as the child of another element, never rendered directly. Please make sure to wrap your element in a proper container. Custom Private Router Component function PrivateRoute({ child ...

Error: Attempting to access 'scrollTop' property of null object in Material UI library

After updating from MUI-4 to MUI-5, I encountered this error. Can anyone provide assistance? ...

Executing a JavaScript function using a parameter passed from an HTML form

I have been working on passing an argument to a JavaScript function called getConfirmation(). The function call is not being executed, and I suspect there might be an issue with the way I am calling it. Can someone please assist me with this? <html> ...

Connecting Behat and Mink to Selenium within Docker: A Step-by-Step Guide

Previously, I had no issues running Behat, Mink, and Selenium standalone server (with Chrome). Now, I am attempting to switch everything over to Docker. I have set up a container for the Selenium hub plus Chrome node using the following commands: docker ...