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
转载请注明出处:http://www.cnblogs.com/tobecrazy/