从属性中获取特定字符串
Get specific string from Attribute
我在 Selenium 中录制了一个脚本 IDE Chrome 附加组件。
我得到了一个变量名,其值 "John Doe (johndoe@abc.com)"
通过 Store Value 命令存储。
我知道执行脚本命令能以某种方式提供帮助。我尝试了一些 javascript 但没有用。
我可以在下一个命令中使用 ${name}
检索名称 + 地址,但我只想要名称,即字符串中只有 "John Doe"。
是的,你是对的。您应该使用 execute script
命令来创建新变量。这是:
execute script | tmp = ${name}; return tmp.substring(tmp.indexOf('(') + 1, tmp.indexOf(')')); | address
execute script | tmp = ${name}; return tmp.substring(0, tmp.indexOf(' (')); | name
我在 Selenium 中录制了一个脚本 IDE Chrome 附加组件。
我得到了一个变量名,其值 "John Doe (johndoe@abc.com)"
通过 Store Value 命令存储。
我知道执行脚本命令能以某种方式提供帮助。我尝试了一些 javascript 但没有用。
我可以在下一个命令中使用 ${name}
检索名称 + 地址,但我只想要名称,即字符串中只有 "John Doe"。
是的,你是对的。您应该使用 execute script
命令来创建新变量。这是:
execute script | tmp = ${name}; return tmp.substring(tmp.indexOf('(') + 1, tmp.indexOf(')')); | address
execute script | tmp = ${name}; return tmp.substring(0, tmp.indexOf(' (')); | name