← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #150882]: Determine if data is entered in fields

 

Question #150882 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/150882

    Status: Open => Answered

RaiMan proposed the following answer:
that depends on what is expected

things like

    (3 blanks)
---
##@-->

will all give size > 0

so if this is ok, len(Env.getClipboard()) > 0 would be ok.

if it should not be empty in sense of readable characters, use:
len(Env.getClipboard().strip()) > 0 (all surrounding whitespace deleted)

Otherwise you can use a regular expression

e.g. at least some letters or digits followed by some other defined
characters are mandatory

import re
not re.match(r"[a-zA-Z0-9]+[a-zA-Z0-9\-+.!?]*", Env.getClipboard().strip()) # if true means valid

(match compares from the beginning of the string, so no leading ^ needed
in the regex)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.