arraysstringsplitselenium-ide

Selenium IDE: Is there an updated method to split a string into an array and pull a position value?


Problem: I know this answer has been posted previously; however, neither of the suggested Selenium IDE methods for extracting a substring value work. Below, I have referenced the posts. However, they are pretty old. Both the suggested methods return the same issue, which is returning the javascript as a string result rather than being executed as a script and returning the array value specified. If I change it up a bit use the variable format @{variable} with execute script, it returns 'undefined' as the result, however, I think I might be on the righ track there but just don't know how to take it further.

What I have tried: I've tried the posted suggestions as well as these of my own, even using execute script besides store and I received 'undefined' but it does not fail.

Other code:

javascript{${edsTotalDocs}.split(" ")[${position}]}

Used with execute script

${edsTotalDocs}.split(" ")[${position}]

What I'm trying to do: I'm trying to capture the large number into a variable (i.e., 46,645)

I think I'm doing it correctly as described in the posts, however, maybe not. I was hoping someone could provide a solution or point out where I'm doing it incorrectly.

Stack Overflow Post

Elemental Selenium

Stack Overflow Post

Current Code:

Current Code

Current Result:

Current Result


Solution

  • I found the solution after posting, and it is less complicated than prior posts. You also want to use execute script vs store because the return will load it into the designated variable, and you don't need to store an array position if you know it, but you could, it just is more work and more steps.

    execute script | return ${edsTotalDocs}.split(" ")[5] | result

    Example String: "Showing 1 to 10 of 46,645 entries"

    Selenium IDE Code Result