allow to set field selector in playwright tests
This commit is contained in:
parent
e4d1e3d7c2
commit
221ea6244d
1 changed files with 12 additions and 4 deletions
|
|
@ -184,10 +184,18 @@ in
|
||||||
type = str;
|
type = str;
|
||||||
default = "[Uu]sername";
|
default = "[Uu]sername";
|
||||||
};
|
};
|
||||||
|
usernameFieldSelector = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "get_by_label(re.compile('${cfg.usernameFieldLabelRegex}'))";
|
||||||
|
};
|
||||||
passwordFieldLabelRegex = mkOption {
|
passwordFieldLabelRegex = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
default = "[Pp]assword";
|
default = "[Pp]assword";
|
||||||
};
|
};
|
||||||
|
passwordFieldSelector = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "get_by_label(re.compile('${cfg.passwordFieldLabelRegex}'))";
|
||||||
|
};
|
||||||
loginButtonNameRegex = mkOption {
|
loginButtonNameRegex = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
default = "[Ll]ogin";
|
default = "[Ll]ogin";
|
||||||
|
|
@ -267,11 +275,11 @@ in
|
||||||
page.goto(testCfg['startUrl'])
|
page.goto(testCfg['startUrl'])
|
||||||
|
|
||||||
if u['username'] is not None:
|
if u['username'] is not None:
|
||||||
print(f"Filling field {testCfg['usernameFieldLabelRegex']} with {u['username']}")
|
print(f"Filling field username with {u['username']}")
|
||||||
page.get_by_label(re.compile(testCfg['usernameFieldLabelRegex'])).fill(u['username'])
|
page.${cfg.usernameFieldSelector}.fill(u['username'])
|
||||||
if u['password'] is not None:
|
if u['password'] is not None:
|
||||||
print(f"Filling field {testCfg['passwordFieldLabelRegex']} with {u['password']}")
|
print(f"Filling field password with {u['password']}")
|
||||||
page.get_by_label(re.compile(testCfg['passwordFieldLabelRegex'])).fill(u['password'])
|
page.${cfg.passwordFieldSelector}.fill(u['password'])
|
||||||
|
|
||||||
# Assumes we don't need to login, so skip this.
|
# Assumes we don't need to login, so skip this.
|
||||||
if u['username'] is not None or u['password'] is not None:
|
if u['username'] is not None or u['password'] is not None:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue