如何以隐藏的形式发送带有硒的密钥

时间:2017-11-24 02:34:00

标签: python selenium

有一个隐藏的表单,我想在python上发送带有selenium的密钥,但是失败了,我怎样才能发送用户名和密码?谢谢

<form action="https://passport.liepin.com/c/login.json" method="post" class="login-box" lt-plugins-valid="0.3955239762649647" style="left: 0px; display: hidden;">
            <input type="hidden" name="layer_from" value="wwwindex_rightbox_new"> 
            <input type="hidden" name="user_pwd" value="">
            <div class="control relative">
                <input type="text" name="user_login" data-nick="login_user" value="" class="text input-xlarge"  data-valid="false">

            </div>
            <div class="control relative">
                <input type="password" data-selector="user_pwd" data-nick="login_pwd" value="" class="text input-xlarge" </div>
            <div class="control relative hide" data-selector="valicode">

1 个答案:

答案 0 :(得分:0)

使用 Javascript 。请参阅代码段:

from selenium import webdriver
wd = webdriver.Firefox()
wd.execute_script("var list = document.getElementsByName('layer_from');
list[1].value='something';
var anotherList = document.getElementsByName('user_pwd'); 
anotherList[1].value='password';")