"Selenium-webdriver self-study" selenium-ide Pattern matching (vi)

Source: Internet
Author: User
Tags glob

==========================================================================================================

Write in front:

Pattern matching can be used when we need to test for dynamic characters or random characters.

==========================================================================================================

6. Selenium-ide Pattern Matching

In the selenium IDE, such as a locator, a pattern is a type of parameter that is often used in selenium. It allows the user to describe the pattern of special characters. Many times, we want to verify that the text is dynamic, in which case pattern matching is very useful.

Pattern matching is used for all authentication point commands-Verifytextpresent,verifytitle,verifyalert,assertconfirmation,verifytext and verifyprompt.

There are three ways to define a pattern-wildcards, regular expressions, and precision.

Wildcard characters

The wildcard has a file matching mode that is already in use in Linux or Windows, while looking for a specific file type, such as * Doc or *. JPG, most technicians. But the selenium only supports three special characters: *,? and [].

*-matches any number of characters.
? -Matches a single character.
[]-the so-called character class, which can match any single character found in parentheses. [0-9] Match any number

To specify the selenium command glob, prefix the keyword with the pattern ' glob: '. For example, if you want to search for the text "tax year 2013" or "tax year 2014," You can use "tax year *" instead, as shown in.

However, the usage of the keyword "glob:" is optional, and the text pattern is specified, because the selenium matching mode is the default.

Precision Mode

The pattern is prefixed with "exact:" to match the given text. The user wants the string value to match exactly, i.e. without the globe operator, we can use the "exact" pattern as shown. In this example, the operator ' * ' will be used as a normal character instead of a pattern-matching wildcard.

Regular expression pattern

Regular expressions are the most useful of the patterns that are available in the matching technique. Selenium supports the full Java language Support Reugular expression mode. Therefore, the user is no longer limited by the *,? and [] Match mode.

To use the regular expression pattern, we need to "regexp:" or "regexpi" with any prefix. The prefix "REGEXPI" is case insensitive. Glob: and exact: The pattern is a subset of the regular expression pattern. Everything is done using glob: and exact: can be done with regular expressions.

Example

For example, the following will test if the field that is entered with the ID "name" contains the string "Tax year", or ' tax year '.

==========================================================================================================

Learning Summary:

1. The concept of sensory pattern matching is similar to that in SQL. However, there is no actual use, later work, to use to share.

Next, learn more about the advanced use of the Selenium IDE.

==========================================================================================================

"Selenium-webdriver self-study" selenium-ide Pattern matching (vi)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.