New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "patterns" for text verification #141

Open
Jarob22 opened this Issue Apr 5, 2018 · 15 comments

Comments

Projects
None yet
10 participants
@Jarob22
Copy link

Jarob22 commented Apr 5, 2018

Raising this after seeing another user talk about it.

The old IDE allowed regex in text verification steps (and possibly other places too) eg

verify text | target | you are the * User to log in today

This should be added to the new IDE as well to keep feature parity.

@98gmarquee

This comment has been minimized.

Copy link

98gmarquee commented Apr 5, 2018

That actual syntax worked? Ha!

I always used 2 xargs with something like

command target value
verifyElementPresent //a@[starts-with(.,'you are the') and contains(.,'User to log in today')]`
@frankkienl

This comment has been minimized.

Copy link

frankkienl commented Jun 7, 2018

Having regex support in the IDE would be really helpful

@tourdedave tourdedave changed the title Using regexp in text verification Add support for "patterns" for text verification Jun 12, 2018

@tourdedave

This comment has been minimized.

Copy link
Contributor

tourdedave commented Jun 12, 2018

Per the old IDE spec:

Patterns are used for various reasons, e.g. to specify the expected value of an input field, or identify a select option. Selenium supports various types of pattern, including regular-expressions, all of which are described in more detail below.

String-match Patterns

Various Pattern syntaxes are available for matching string values:

glob:pattern: Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a kind of limited regular-expression syntax typically used in command-line shells. In a glob pattern, "*" represents any sequence of characters, and "?" represents any single character. Glob patterns match against the entire string.
regexp:regexp: Match a string using a regular-expression. The full power of JavaScript regular-expressions is available.
regexpi:regexpi: Match a string using a case-insensitive regular-expression.
exact:string: Match a string exactly, verbatim, without any of that fancy wildcard stuff.
If no pattern prefix is specified, Selenium assumes that it's a "glob" pattern.

For commands that return multiple values (such as verifySelectOptions), the string being matched is a comma-separated list of the return values, where both commas and backslashes in the values are backslash-escaped. When providing a pattern, the optional matching syntax (i.e. glob, regexp, etc.) is specified once, as usual, at the beginning of the pattern.
@tourdedave

This comment has been minimized.

Copy link
Contributor

tourdedave commented Jun 12, 2018

Once this gets implemented, we'll need to remember to update the documentation accordingly.

@AyaSF

This comment has been minimized.

Copy link

AyaSF commented Jun 16, 2018

Hi,
I have the same problem: the wildcard * is missing.
Thanks by advance for the improvment,
AyaSF

@corevo corevo added the selenium api label Jun 19, 2018

@stuart1975

This comment has been minimized.

Copy link

stuart1975 commented Jun 21, 2018

Hi,
I am using Firefox Version 60.0.2 and Selenium IDE 3.0.30. Wildcards are not working.
I use command: "verify text" put in value field the following:

glob:items found
and got the following error message:

Actual value '2,480 items found, displaying 1 to 20.' did not match 'glob:items found'

@tourdedave

This comment has been minimized.

Copy link
Contributor

tourdedave commented Aug 22, 2018

@cinnest There's a generic assert command. You can use it to check a variable against an expected value.

@corevo

This comment has been minimized.

Copy link
Member

corevo commented Aug 22, 2018

I'm thinking we can add regex pretty easily, I think that glob is the issue, since JavaScript doesn't have a default glob implementation, and I don't wanna bundle that with the runner.
First off we can definitely add regex, globbing though, I see 2 solutions:

  • Bundle a globbing library with the runner
  • Convert globs to regexes in Selianize

\cc @tourdedave

@cinnest

This comment has been minimized.

Copy link

cinnest commented Aug 22, 2018

@tourdedave Sorry for deleting my comment. I've realized @98gmarquee had already mentioned a workaround and therefore I though my question was not relevant. It is nice tough knowing that with the assert I could indeed verify a variable. thanks

@VChris1975

This comment has been minimized.

Copy link

VChris1975 commented Sep 5, 2018

I'm trying Selenium IDE 3 Chrome plugin for some days. It's a great and powerful tool, but I am unable to perform the most important test... How to test if a piece of text is present inside a div?
asterisk character as wildcar not working in verify text, assert text, etc... There is no verify text present command.
I was trying everything but I am unable to find out a solution?
Why there is no substring, or * as wildcard, or a command to check a text exist somewhere on the page or inside a div?
Or if there is a solution, can somebody help me how to perform it step by step?
Selenium IDE 3.x

@cinnest

This comment has been minimized.

Copy link

cinnest commented Sep 6, 2018

@VChris1975 I was facing a similar issue and it took me a while 'til I realize @98gmarquee had already given a solution for that: with the use of xpath and the verifyElementPresent you can check if a given element contains a string. In my case I was verifying the presence of a string in a table, so I solve the problem with the following command:

{
      "id": "90ab24b6-959a-4a98-9ef1-652bfd01c64b",
      "comment": "",
      "command": "verifyElementPresent",
      "target": "xpath=(//table[contains(.,${myString})])",
      "targets": [],
      "value": ""
    }

I guess you could use this solution too...

@VChris1975

This comment has been minimized.

Copy link

VChris1975 commented Sep 6, 2018

@cinnest : thanks for your reply! I understand the logic, it's a very clever solution. Nice :)

@saca-puntas

This comment has been minimized.

Copy link

saca-puntas commented Dec 13, 2018

Hi, I'm still new to GitHub-- does the fact that this issue is still open mean that adding wildcard support is still something that is planned to be done? None of the workarounds work for my scenario and there are many places I used a wildcard in the old version that makes it really valuable to me.

@98gmarquee

This comment has been minimized.

Copy link

98gmarquee commented Dec 14, 2018

I hope it's still on the cards to do. I really could have used it today... after stringing together 7 contains(.,'stuff') to verify many sentences on various pages. Stupid things had tabs and new lines in them and I couldn't get a direct text match.

@corevo

This comment has been minimized.

Copy link
Member

corevo commented Jan 9, 2019

Yes, this issue is open, and we'll get to it eventually, if someone wishes to contribute we'd love the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment