Selenium 模拟人输入


public
static void type(WebElement e,String str) throws InterruptedException { String[] singleCharacters = str.split(""); // Interval is 0.5 second between each type of character, this is to // simulate real human action for (int i = 0; i < singleCharacters.length; i++) { if (singleCharacters[i]!="") { e.sendKeys(singleCharacters[i]); Thread.sleep(500); } } Thread.sleep(1000); }

在sendKeys时,把字符串拆分成单个字符,使用间隔0.5s

posted @ 2014-11-17 17:16  to be crazy  阅读(1677)  评论(0编辑  收藏  举报