How can you confirm the presence of a specific word within a variable using Selenium?

I need assistance in verifying if a string contains a specific word using variables.

Suppose I have a variable named options with the value "test,test2,test3". I want to check if this string includes the word test2.

This is what I have attempted so far:

  1. Command: store // Target: test,test2,test3 // Value: options
  2. Command: storeEval // Target: javascript{storedVars['options'].includes("test2");} // Value: result

I want Selenium to store TRUE or FALSE in the variable "result" based on whether it finds the word 'test2' in the string or not. However, I encounter the following error:

[error] Unexpected Exception: TypeError: storedVars.options.includes is not a function. fileName -> chrome://selenium-ide/content/selenium-core/scripts/selenium-api.js, lineNumber -> 2545

Any suggestions?

Screenshot:

Answer №1

javascript{storedVars['options'].search("test2");} has successfully executed.

Answer №2

If you are working within the IDE, you can execute the following command:

checkText | storedVars['choices'] | evaluation

If the specified text is located, this command will result in a passing outcome (displayed in green). Conversely, it will show as failing (in red) if the text cannot be found.

Klendathu

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

Guide to selecting a checkbox within a div-table using Selenium and VBA

I've experimented with different methods to select a checkbox within a <div> <table id="Table1" class="Foresttable" style="width: 100%;" cellpadding="3" cellspacing="0" border="0&quo ...

JavaScript Autocomplete Validation

I'm working on a web page that has two TextBoxFor fields with Javascript autocomplete. The first field, ClientUser, receives a response that includes both an integer and a string. I need to compare this integer with another integer field on the page, ...

Troubleshooting Problem with Facebook Messenger Bot Webhook

I received the following notification: Your Webhooks subscription callback URL is not currently accepting updates. We have observed that your Webhooks subscription for callback URL has been inactive for at least 16 minutes. Please ensure that your cal ...

Filtering data within a specific date range on an HTML table using JavaScript

I am attempting to implement a date filtering feature on my HTML table. Users should be able to input two dates (From and To) and the data in the "Date Column" of the table will be filtered accordingly. The inputs on the page are: <input type="date" i ...

Item 'unreachable' displayed in Firefox console

I am working with several divs that have the class='class_name'. I have also defined var A = document.getElementsByClassName('class_name'); console.log(A[0]); Upon checking in the Chrome console, it displays: <div class="class_n ...

The initial Ajax request returned an empty data string, but upon retrying, the correct data

Let's address the current situation Previously, I had a free domain that was unexpectedly closed by the web admins without any explanation. Everything functioned perfectly on that domain, but after opening a new one on a different site, I started enc ...

Having difficulty converting the string data to HTML using JavaScript in a Node.js Express application

In my app.js file, I will be sending data to an EJS file. app.get('/', function (req, res){ Blog.find({}, function(err, fountItems){ Blog.insertMany(defaultBlog, function(err){ }) } res.render( ...

What is the best way to create a sleek typewriter effect transition by hovering between tabs?

When hovering over a tab, the content in the main content area's child div should be displayed from a sibling div that holds the content. Initially, the details div style is set to hide the contents but upon hover, it is displayed. The described func ...

Using Vuejs to implement scrolling to the top of a specific div element

I have a division containing text, and when I submit that text, new data is obtained from the server. If I happen to be at the bottom of the original text, the newly received text also appears at the bottom. Ideally, I would like the page to scroll up to ...

Error encountered with Node.js clustering

Hey there! I'm currently diving into the world of node.js and javascript. My goal is to build a cluster.js using the nodejs cluster module, where at the end of my if statement I invoke server.js to kickstart the application. Here's my cluster.js ...

Replace a function within the UI-Bootstrap framework

Incorporating the angular-bootstrap library into my app via bower has been a game changer. Although I am currently stuck with an (outdated) version that includes a pesky bug, upgrading is not yet feasible in my scenario. I considered inserting a customiz ...

The problem encountered with Angular ngrx: TypeError when attempting to freeze array buffer views containing elements

I'm running into a problem with ngrx. I have an array in my state to which I am trying to add objects. Everything seems to be working fine as I can see the values in my store when I console log them. However, the redux dev tools and console are throwi ...

Loading data dynamically in the Highcharts ng library allows for real-time updates to the

I'm currently working on integrating highcharts ng into my Angular project, but I'm encountering issues with data not populating. It seems like there might be a problem related to the loading of the DOM and the function call. Here's my HTML ...

The hamburger menu unexpectedly appears outside the visible screen area and then reappears at random intervals

My website has a hamburger menu for mobile devices, but there's a problem. When the page loads on a small screen, the hamburger menu is off to the right, causing side scrolling issues and white space. I thought it might be a CSS problem, but after exp ...

Managing timestamps of creation and modification with Sequelize and Postgresql

As a newcomer to Sequelize, I find myself grappling with the intricacies of model timestamps management. Despite prior experience with another ORM in a different language, I'm struggling to wrap my head around how to automatically handle "createdAt" a ...

Preventing the opening of a past event's modal dialog in jQuery

I am having trouble with setting up the jquery full calendar. Whenever I click on a past event, the modal opens when it shouldn't. Only current and future events should trigger the opening of a modal. eventRender: function(event, element, view) { ...

Managing checkbox inputs within a MEAN stack application

As someone who is brand new to the MEAN stack, I've been experimenting with saving an array of checkbox values and retrieving them from MongoDB. I've set up a clear schema for embedded arrays using Mongoose, but I'm struggling with how to in ...

What is preventing me from utilizing FindElementByXPath on the table from this website?

I am currently using VBA for web scraping with Selenium and ChromeDriver. After logging into a website at , I encountered a table on the main page that contains a lot of information. By inspecting the element, I found the table object highlighted in this ...

Convert a Material UI dropdown into a Bootstrap dropdown

The reason for this transformation is due to the unsightly appearance of the dropdown from Material UI. Despite that, the code is functioning properly. It features a dropdown with multiple choices, loading a list of strings and their corresponding images. ...

Guide on passing a variable from AJAX response to a JavaScript function when a user clicks

I need to send the value of a variable as a parameter to a javascript function when clicking on a link. The value is obtained from an AJAX response. However, I am encountering an error in the console stating that 'test' is not defined. var test ...