如何在UIAutomation中从句子中获取特定单词?

时间:2012-10-10 14:39:03

标签: ios instruments ios-ui-automation

如果我需要检查某个句子中是否存在某个特定单词,那么我应该在javascript中使用什么语法/代码进行UIAutomation?

1 个答案:

答案 0 :(得分:0)

使用函数indexOf():

在字符串中搜索“welcome”:

 var str="Hello world, welcome to the universe.";
 var n=str.indexOf("welcome"); 

n 的结果将是:

13

如果要搜索的值不存在,则此方法返回-1。