【问题标题】:Get specific string from Attribute从属性中获取特定字符串
【发布时间】:2020-02-13 19:26:18
【问题描述】:

我在 Selenium IDE Chrome 插件中录制了一个脚本。

我得到了一个变量名,其值为由 Store Value 命令存储的 "John Doe (johndoe@abc.com)"。

我知道执行脚本命令会有所帮助。我尝试了一些javascript,但没有用。

我可以在下一个命令中使用${name} 检索名称+地址,但我只想要名称,即字符串中的“John Doe”。

【问题讨论】:

  • 请分享您到目前为止尝试过的代码以及您遇到问题的地方。
  • 我使用的是 Chrome 插件
  • 下面的答案解决了我的问题。谢谢

标签: google-chrome selenium-ide


【解决方案1】:

是的,你是对的。您应该使用execute scriptcommand 创建新变量。这里是:

execute script | tmp = ${name}; return tmp.substring(tmp.indexOf('(') + 1, tmp.indexOf(')')); | address
execute script | tmp = ${name}; return tmp.substring(0, tmp.indexOf(' (')); | name

【讨论】:

  • 谢谢,我只是将它更改为与美国日期格式匹配,它可以工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-09-29
  • 2011-05-13
  • 1970-01-01
  • 2013-11-20
  • 2017-07-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多