它已经是众所周知的错误,通常有三种方法来避免它:检查重叠、设置睡眠时间以完全下载页面、检查元素是否可见。 我都试过了,但都不管用。 好: 我在使用twitter页面 https://api.twitter.com/oauth/authenticate?oauth_token=3b8ougAAAAAABl35AAABWpZgqDA 文本字段有HTML:
<label for="username_or_email" tabindex="-1">Username or email</label>
<input aria-required="true" autocapitalize="off" autocorrect="off" autofocus="autofocus" class="text" id="username_or_email" name="session[username_or_email]" type="text" value="">
我试过密码:
^{pr2}$我把代码绑在一起:
def input_id:
links = get_driver().find_elements_by_xpath("//input[@id='username_or_email']")
if links:
links[0].send_keys(str(UserName))
else:
raise ValueError('Field with id username_or_email not found')
我试过在发送密钥之前点击这个元素,没有。但我所有的解决办法都不管用。我总是收到一条错误消息“元素在点上不可点击…”。 有什么建议吗?在
你的第一次尝试是向标签发送文本。你的第二次尝试是正确的。但是,}:
input
元素没有id
属性。将id
更改为name
,然后将links[0].send_keys()
更改为{编辑:为了澄清一下,我看到你发布的HTML中有一个
id
属性,但在我能找到的Twitter登录元素中却没有这个属性。在编辑2:如果问题与脚本尝试填充凭据之前未完全加载元素有关,请尝试使用
^{pr2}$WebDriverWait
。例如:相关问题 更多 >
编程相关推荐