Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automating Form filling #5

Open
niloy opened this issue Sep 25, 2013 · 3 comments
Open

Automating Form filling #5

niloy opened this issue Sep 25, 2013 · 3 comments

Comments

@niloy
Copy link
Owner

niloy commented Sep 25, 2013

Automating Form filling

So here is a fun way to fill forms with random values for testing them in
the development phase. Open up the javascript console and execute the
following code:

(function() {
    var elements = [];

    [].push.apply(elements, document.querySelectorAll("input[type=email]"));
    [].push.apply(elements, document.querySelectorAll("input[type=text]"));
    [].push.apply(elements, document.querySelectorAll("input[type=password]"));
    [].push.apply(elements, document.querySelectorAll("input[type=search]"));
    [].push.apply(elements, document.querySelectorAll("textarea"));

    elements.forEach(function(e) {
        e.value = "test_" + Date.now();
    });
}());

Simple script to automate form filling for fun and profit. Try it on the facebook login page.

@manojyadav
Copy link

Good example, is there any reason not to use elements.push.apply instead of [].push.apply as elements is also array.

Example with elements.push.apply and comma separated querySelectorAll

(function() {
    var elements = [];
    elements.push.apply(elements, document.querySelectorAll("input[type=email], input[type=text], input[type=password], input[type=search], textarea"));
    elements.forEach(function(e) {
        e.value = "test_" + Date.now();
    });
}());

@niloy
Copy link
Owner Author

niloy commented Sep 25, 2013

is there any reason not to use elements.push.apply instead of [].push.apply as elements is also array

No special reason, I just save 6 characters of typing 😃

@manojyadav
Copy link

Okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants