Address: http://blog.csdn.net/ffb/article/details/38559655
Currently, browsers have the function of automatically filling in forms, which greatly saves us some common forms, especially the time for entering login forms.
However, with the development of user requirements, many web pages use JavaScript to submit forms in real time. These operations may not involve actual submit operations at all, so it will not be intercepted and recorded by the browser. At this time, it will be very depressing to face some common forms that need to be repeated.
However, in this case, you can still manually "automatically fill the form" by using the console function of chrome. You can press F12 on the page to enter the form and click console.
In this test, the form can be automatically filled in at least two ways:
Assume that five input boxes are required: name, address, port, user name, and password.
Method 1:
If these input boxes have IDs, paste the following code in the console and press Enter:
void((function(){document.getElementById("name").value = "localpc";document.getElementById("host").value = "127.0.0.1";document.getElementById("port").value = "22";document.getElementById("username").value = "root";document.getElementById("password").value = "root";// document.getElementById("login").click();})())
The value can be modified according to the actual situation.
Method 2:
If these input boxes only have name and no ID, the following method can automatically fill in the Form (the same is to paste it to the console and press Enter ):
$('[name=name]').val('localpc');$('[name=host]').val('127.0.0.1');$('[name=port]').val('22');$('[name=username]').val('root');$('[name=password]').val('root');
After actual tests, although it is not as good as the automatic completion of the browser, the efficiency is improved a lot. More importantly, it is very practical to enter common forms without occasional mistakes.