Automate browser operations

Sometimes you just want to automate tedious clicking tasks in the browser. You will learn how to do this in this tutorial. https://youtu.be/Xv9rokKD6_U

Step 1: Analyze website

When automating, it is usually about entering text into specific fields or clicking certain buttons. These input fields must be located to later tell the browser in which input fields something should be entered. By right-clicking on the element and clicking "Inspect" in the context menu, the HTML view opens at the bottom of the browser and highlights the current element. You now locate the individual elements as follows:

Step 2: Ensure that jQuery is present

When in the Inspect Element view, there is a text line at the bottom that usually starts with a >>. This is where you enter JavaScript commands. Now, the jQuery library must still be loaded. You check this by typing "$" there and pressing ENTER. If "function()" appears as a response, jQuery is properly loaded. If "undefined" appears instead, we still need to load it. This is done by entering the following command and pressing ENTER: "script = document.createElement('script'); script.src = 'https://code.jquery.com/jquery-latest.min.js'; document.body.appendChild(script);". Subsequently, entering "$" should return a "function()".

Step 3: Automatically fill input fields

From Step 1, we have selected the selectors for the input fields. We now use these in a command: $('hier Selektor eintragen').val('hier Wert eintragen'); Example: $('#url').val('http://launix.de'); If you want more than just static text in the values, such as the first and last name of the Xing contact for whom you are sending the contact request, simply dive a bit deeper into JavaScript and jQuery. It is fundamentally quite simple once you have understood the basic mechanisms.

Step 4: trigger the click

From step 1, we identified the selector for the submit button. We will now trigger the click for this: $('hier Selektor eintragen').click(); Example: $('input[type="submit"]').click();

Conclusion

I have already saved hours of work or been able to accomplish thousands of things more than if I had done everything manually.
Categorias
Etiquetas