Is it possible to use Selenium IDE to navigate if a variable contains a specific string

Thank you for taking the time to review this.

I have developed a script that scans a web page to verify if a specific text string is present. If it is not found, the script will loop. The issue I am facing is that I am required to input every single word of the string for the gotoif command to recognize it. Is there a way for the gotoif command to search for a variable that CONTAINS the specified string?

This is the code snippet I am currently using:

<tr>
    <td>gotoIf</td>
    <td>storedVars['activetext']=='This should trigger the gotoif'</td>
    <td>silencemethod</td>
</tr>

Unfortunately, the mentioned code only activates the gotoif when the entire string matches exactly as specified.

Answer №1

The gotoIf function evaluates the following line as a JavaScript statement and verifies its truth or falsity. An example usage would be:

storedVars['activetext'].includes('some text')

This will determine if the text "some text" has been stored in the activetext variable.

Answer №2

Implemented based on the suggestion from @MoldovanHipster, the following is the complete example of Selenium IDE code:

Step 1: Determine if the variable 'Name' contains the word 'eway' and return a true or false message accordingly

storeEval  
storedVars['Name'].indexOf('eway') > -1  
ewayYeah 

Step 2: If the value is true, proceed to the 'eway' label

gotoIf  
'${ewayYeah}' == 'true'  
eway 

Step 3: If the value is false, display an alert message

storeEval  
alert('This is NOT eway!')   

Step 4: If the value contains 'eway', display the appropriate alert message

label  
eway   

storeEval  
alert('This is eway!') 

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

Encountered an issue while attempting to start the JavaScript debug adapter in Visual Studio

When attempting to debug my script code in Visual Studio, I encountered an error. How can I resolve this issue? ...

I need to change a website into a string so that I can analyze it with javascript. How can I do this?

Currently, I am in the process of creating a website for my video game servers. The admin tool we use outputs the current server status in a .json format as a large text string to this specific URL: My goal is to retrieve the entire text string from the p ...

Automatically populate a div with content from a file

As I am completely new to the world of HTML, I find myself in need of quickly putting together something for work just as a proof of concept. I apologize if this question has been answered previously, but honestly, I wouldn't even know how to start se ...

Tips for establishing the perfect profile for Firefox in Selenium WebDriver

Despite having the following Selenium code in Python set up to utilize my Firefox profile and avoid the need to log in to frequently visited pages, the browser still doesn't seem to remember my login information or maintain me logged in. What could be ...

Creating customizable Isotope objects using custom CSS margins that are influenced by the child-nth selector and JavaScript

My recent project involved creating a simple .isotope gallery, and when viewing the selected #portfolio-wrap container in Chrome Dev Tools, here is how it appears: Unfortunately, I am unable to upload three links here. Please visit this link for more info ...

Steps for transitioning a VUE JS project to TypeScript

Is it possible to transition a VUE JS project from JavaScript to TypeScript without rewriting everything? I heard from a friend that it can be done through the VUE CLI, but I haven't been able to find any documentation or articles on this method. Has ...

Ensure there is a sufficient gap between the top and bottom icons within the Material-UI Drawer

I'm having difficulty articulating this, but I'd like to add two different sets of icons to the Drawer component. Set 1 should be displayed at the top in a standard column format, similar to the examples provided by them. Set 2 should go at the b ...

Strategies for disabling middle mouse button default behavior in Vue

When I use @click.middle.stop.prevent="test", the default scroll wheel still shows up despite it detecting the middle mouse click and calling my function. Is there a way to prevent this from happening? ...

How can I incorporate percentage values into input text in Angular?

How can I include a percent sign in an input field using Angular, without relying on jQuery? I am looking for a solution that is identical to what I would achieve with jQuery. Here is the current status of my project: ...

Display a notification upon successfully submitting data in Laravel and Vue.js

Hello there; I am new to Laravel and Vue.js. I have encountered an issue when submitting a form with validation problems. The error message for a required input field, such as the "Brand Name" field, appears correctly, but after successfully submitting the ...

Summernote - When validating text, it is shown as raw HTML

I have integrated Codeigniter with Summernote on the frontend. In a form, if certain fields are left empty, the same page reloads for validation checking. The JavaScript and CodeIgniter code I am using is as follows: $(window).load(function(){ &l ...

Storing data in localStorage and serializing it using JSON.stringify and

Currently, I am developing a project that enables users to share memories of places they have visited and also tracks the location and time when the memory was recorded. One hurdle I'm facing involves incorporating localStorage into the application. I ...

How to retrieve multiple checked values from checkboxes in Semantic UI React

Trying to enable users to select multiple checkboxes in react using semantic-ui-react. I am new to react. Here is my code: class ListHandOver extends React.Component { state = { data: {} } handleChange = (e, data) => { console.log( ...

Issues with Selenium and Chromedriver: interacting with elements may not be possible

After spending a couple of weeks with Selenium, I've encountered an issue with my script. Everything was working perfectly until the website owner made some code updates, resulting in me not being able to log into the site. Despite updating Chrome Dr ...

Transferring an array from PHP to jQuery through the use of AJAX

My JavaScript code communicates with a PHP page to retrieve data from a database and store it in an array. Now, I would like to use jQuery to loop through that array. This is how the array is structured: Array ( [0] => Array ( [image] => articl ...

The React task list updates the todo items on change, rather than on submission

As a newcomer to React, I have embarked on the classic journey of building a todo app to learn the ropes. Everything seems to be functioning smoothly except for one minor hiccup: When I input a new todo and hit "submit", it does get added to my array but d ...

Creating Class Names Dynamically in Angular 2 Using ngFor Index

Encountering an issue while trying to generate a dynamic class name based on the ngFor loop index in Angular 2. Due to restrictions, I had to use a specific syntax as Angular 2 does not support ngFor and ngIf together on the same element. Given this setup ...

Troubleshooting issues with filtering two MongoDB arrays in ES6 and finding a solution

I have a scenario where I am requesting two arrays of objectIDs from MongoDB, and then attempting to identify the differences between the two arrays. In addition, I am passing these arrays through express middleware using res.locals. Below is the code sn ...

Extract information from a web address to display on a web page

Can I link specific information from different URLs, such as the number of views on a YouTube video, to my website using jQuery or JavaScript? I attempted the following: <script> $(document).ready(function(){ $('#response').load(&apos ...

Placing information onto a fresh Google browser tab

Hello, I am a beginner in programming, specifically Python Selenium. I have encountered an issue with pasting data into an input box. It seems that when I try to paste data on one website, everything works fine. But if I attempt to paste the same data on a ...