Automated test Learning (vi) text template matching for selenium command

Source: Internet
Author: User
Tags character set

Text template Matching

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

Text template matching can actually be understood as wildcard characters. I think everyone has used the search function of the Windows system itself.

* The asterisk represents one or more characters.

? The question mark represents a character.

A template is also a parameter that is often used by selenes commands; The template allows you to use special characters to describe expectations rather than accurately illustrate expectations.

The commands in the selenium that require a template include:

Verifytextpresent, Verifytitle, Verifyalert, Assertconfirmation, Verifytext, Verfyprompt,

So what are the model types?

Generally we have three kinds of commonly used: globbing, regular expressions, Exact.

First, globbing model

Many people are familiar with globbing because it is used as a wildcard in DOS or hungry unix\linux commands. In the selenium implementation, Globbing supports only two special symbols:

1) * means "match anything", empty, one or more characters

2) [] (character set) means "match the characters in any square brackets". Connectors can be used to shorten the poor-lift character (must be contiguous within the ASCCII character set).

Example:

[AEIOU]----match any lowercase vowel letter

[0-9]-----Match any number

[a-za-z0-9]------matches any letter or number

In order for the Selenese command to indicate the use of the globbing template parameter, you can precede the template with the "Glob:" prefix. Of course globbing is the default template mode, so it is also possible to do so without adding.

Second, regular Expressions model

The regular expressions template is the most powerful of the three template types supported by Selenese. Regular expressions is also supported by many high-level languages.

For example: Suppose your test needs to keep only numbers in a particular table cell, regexp:[0-9]+ is a simple template that can match any length of the decimal number.

Regular expressions All special characters that support JavaScript. The table is as follows:

The regular expressions template in Selenese must be added "regexp:" or "REGEXPI:"; the former is sensitive to case sensitivity, and the latter is insensitive to case.

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.