Experiencing a lack of output when splitting a string using Selenium

Having trouble with a selenium javascript code that splits a string? Here's the specific code:

<tr>
    <td>storeEval</td>
    <td>var dList = '${StaffAdminEmail}'.split('@'); </td>
    <td>dsplit1</td>
</tr>

<tr>
    <td>echo</td>
    <td>${dsplit1}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>day = '${dsplit1}';</td>
    <td>dsplit2</td>
</tr>
<tr>
    <td>echo</td>
    <td>${dsplit2}</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>id=school_permalink</td>
    <td>${dsplit2}</td>
</tr>

Here is where the issue might be occurring:

${StaffAdminEmail} <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2ffa7baa3ffb0b30090909093ddbdb8">[email protected]</a>

If you have any insights on how to solve this problem, please let me know!

Answer №1

It seems like there are a few assumptions that need to be made in order to understand your goal here.

Based on the information you provided regarding

${StaffAdminEmail}<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="437e263b222e332f2603263b222e332f266d202c2e">[email protected]</a>
, it appears that you are looking to extract two parts: dsplit1=example (before the @) and dsplit2=example.com (after the @). I will not be utilizing the variables dlist or day as their relevance is unclear.

By using the JavaScript function split(symbol), you can separate the strings based on the specified symbol (in this case, '@'). The individual strings within the resulting array can be accessed using indexing such as [0], [1], and so on.

To assign the extracted components of StaffAdminEmail to dsplit1 and dsplit2, you can try the following:

<tr>
  <td>storeEval</td>
  <td>storedVars['StaffAdminEmail'].split('@')[0]; </td>
  <td>dsplit1</td>
</tr>
<tr>
  <td>storeEval</td>
  <td>storedVars['StaffAdminEmail'].split('@')[1]; </td>
  <td>dsplit2</td>
</tr>

If you require further clarification or if my interpretation of your objective is incorrect, please feel free to ask in the comments.

(Additionally, if you found my response to your previous inquiry helpful, consider accepting it as an answer or at least giving it an upvote.)

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

multiple urls causing duplication of states in angular ui routes

Currently, I am faced with an issue while using angularjs in combination with angular ui routes. The problem arises when dealing with multiple URLs for a single route. I have a state named "bookDetails" which corresponds to a book that has a unique id an ...

Error: WebDriverException: The 'geckodriver' executable must be located in the PATH directory

Operating System: Windows 7 Selenium Version: 3.0.1 Mozilla Firefox Version: 48.0.2 Encountered an error: File "C:\Users\LENOVO\Desktop\kk2.py", line 4, in <module> driver = webdriver.Firefox() File "C:\Python27\l ...

Exclusive event triggered in Blazor only upon changing the page location

Just starting out with Blazor. I've been working on a Blazor project that utilizes DevExpress components, causing some issues with scrolling. My goal is to have the page start at the top every time I navigate to a new page. Currently, I've found ...

Missing RequestVerificationToken value when hiding HTML element using jQuery

I am encountering an issue with my ASP.NET MVC 4 form that involves checkboxes being used to show and hide certain HTML elements. When I initially visit the form page, the RequestVerificationToken value is correctly created as a hidden field. Some HTML ele ...

Removing the cloned element is not possible

In my grid, there is a feature where hovering over a box creates a clone of that box which is positioned directly above it (using z-index/overlay). Once the user moves the cursor away from the box, an animation should play, and at the end of it, the box sh ...

Vue is warning that duplicate keys have been detected, specifically with key x. This could potentially lead to an update error. It is important to prevent adding an item that has already been

I'm working with a v-autocomplete that iterates through a list of users. Once I select a user and add them to another list using a button click, I want to prevent adding the same user again by comparing their unique key. How can I implement an alert i ...

What is the best approach to managing a standard form in React without utilizing AJAX?

Trying to access an endpoint https://api.com/signup.ashx is causing CORS issues. I have been instructed to make the API call without using axios or fetch. Here's what I attempted: const handleSubmit = async (event) => { let error = false ...

Tips for avoiding double reservations and creating time slots with nextjs and prisma

Welcome to my NextJS app booking system. As a beginner, I'm exploring how to create a website for simple bookings and have successfully connected it to Netlify. Currently, I can gather booking details such as time and name using Netlify forms. Howeve ...

Utilizing radio type as a button while excluding the need to submit a form

I have implemented radio type buttons in my form: <div class="d-block"> <div class="btn-group" role="group" aria-label="Basic example"> <button type="radio" name="type" value= ...

A step-by-step guide on implementing a callback function

I am eager to incorporate a callback into this script - specifically the third callback onSlideChangeStart(swiper) found at http://idangero.us/swiper/api/#.V9CMp5grJlY. Since I have never worked with callbacks before, I am unsure of where to begin. In es ...

Tips for sorting items in Wordpress with JavaScript / on click?

I am currently utilizing a method similar to the one outlined in this resource from w3 schools for filtering elements within divs. However, I am facing challenges when attempting to integrate this script into my Aurora Wordpress site due to the removal of ...

Issue with MUI toggle switch not updating display and value upon clicking once

I'm currently experiencing issues with a Material UI toggle switch in my project. Initially, when the component loads, the console log displays the correct value. However, when I toggle the switch from 'yes' to 'no', the visual cha ...

Is it possible to create an array that organizes monthly income data from a JSON file?

I'm currently developing an Accounting System where I need to display a bar chart showing the monthly Incomes and Expenses. The data is retrieved from a database using AJAX, and it returns the following JSON: { "results":{ "his ...

What is preventing this Java code from writing the complete list to the text file?

I am facing an issue with my Java code that prints the text of all the web elements in the console. When I try to write this output to a text file, it only captures an incomplete list and misses out on the last 50-60 web element texts. Any idea why this ...

Combining various JavaScript methods allows for the creation of complex

axis.remove(xaxis).remove(yaxis).remove(zaxis); Is there a way to condense these three removals into a single line (perhaps with regex)? This code snippet is related to the three.js library. ...

"Whenever an action is dispatched in Redux, the bindActionCreators method is involved

After spending 20 hours testing, I am still unable to figure out where I went wrong. Everything works perfectly when I use a store redux dispatch, but now I want to use actions with bindActionCreators. This is my action: import {bindActionCreators} from ...

Is there a way to retrieve an HTTP response using Python and the Selenium driver?

I need assistance in obtaining the HTTP response of a page's URL using selenium webdriver. Could someone please provide guidance on how to achieve this? I have been attempting to accomplish this task using code that I discovered elsewhere. from sele ...

Different ways to eliminate unnecessary items in an array

One task I have is to eliminate all duplicate elements within an array, as shown in the example below: var arr = [ {'seriesIndex':1,pointIndex:0}, {'seriesIndex':1,pointIndex:1}, {'seriesIndex':0,pointIndex:0}, ...

Javascript and the Cookie Conundrum

My goal is to use Javascript to create a cookie that stores the value of an input field with the id "username" every time a button is pressed. Then, I want to retrieve and display that cookie value on the website. I attempted to implement this myself to te ...

Why isn't the color of the circle changing in the console when I type this.fill = "black"?

I am creating circles as a hobby, using a function to generate them. However, I am facing an issue with changing their parameters in the console after creation. Specifically, I am unable to change them in this manner and I'm wondering why not. a.fill ...