相信各位看官在用selenium时,会发现发送长字符时,一个字符一个字符在输入,特别在使用chrome时,更加明显。
如果你的网页是要大量编辑的怎么处理呢?
一、send_keys机制
既然问题出来了,我看就先看看send_keys是怎么实现发送字符的,为什么这么慢呢?看看webdriver的源码吧
def send_keys(self, *value): """Simulates typing into the element. :Args: - value - A string for typing, or setting form fields. For setting file inputs, this could be a local file path. Use this to send simple key events or to fill out form fields:: form_textfield = driver.find_element_by_name('username') form_textfield.send_keys("admin") This can also be used to set file inputs. :: file_input = d