刚刚开始使用selenium,这是页面的HTML:
<div id="signInForm">
<form action="/cgi-bin/VmLoginCgi" method="POST" name="signIn1" id="signIn">
<h2 id="loginTitle">Sign in to view and change your settings</h2>
<div class="field formField noHint username clearfix">
<label for="username"></label>
</div>
<div style="position:relative;" class="field formField noHint password clearfix"><label for="password">Settings Password</label><input type="password" autocomplete="off" value="" maxlength="15" class="name required onefiftyPX inactive" name="jgwhnZLOXn" id="password" onkeypress="handleKeyPress(event)"></div>
<div>
<a href="javascript:SignIn()" class="newCta ctaLarge ctaPrimaryLarge floatLeft">Sign In</a>
</div>
</form>
<p>
<span style="font-weight:bold;">Don't know your password?</span><br>You'll find your default password on the bottom of your Super Hub.
</p>
</div>
我通过以下操作填写文本框:
ele = browser.find_element_by_id("password")
ele.send_keys("supersecretpassword")
但是不能通过执行javascript提交实际的表单。我试过:
browser.execute_script("SignIn()")
但是有一个很长的错误,有什么提示吗?你知道吗
提交带有
submit()
的表单:它将找到元素的父窗体并提交它。你知道吗
或者,如果在您的情况下这不起作用,请找到
Sign In
按钮并单击它:相关问题 更多 >
编程相关推荐