【问题标题】:How to search for a substring in a string in iOS automation scripting? indexOf() and search() methods are not working如何在 iOS 自动化脚本中搜索字符串中的子字符串? indexOf() 和 search() 方法不起作用
【发布时间】:2013-05-08 09:51:14
【问题描述】:

如何在iOS自动化脚本中搜索字符串中的子字符串? indexOf() 和 search() 方法不起作用。

【问题讨论】:

  • 尝试使用正则表达式。你想检查子字符串的存在还是必须得到子字符串的位置
  • 我想检查子字符串的存在。你能详细说明我可以使用哪个正则表达式吗?
  • 您在跟踪日志中收到什么错误消息? search 和 indexOf 似乎都对我有用。

标签: javascript ios ui-automation ios-ui-automation xcode-instruments


【解决方案1】:
var text = target.frontMostApp().navigationBar().staticTexts()[0].value();
var index = text.indexOf("text that looking for");
UIALogger.logDebug("index is: " + i); // -1 means not found

已经测试过了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-02
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    • 2021-03-22
    • 2013-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多