![]() |
VOOZH | about |
Python scripting is one of the most intriguing and fascinating things to do meanwhile learning Python. Automation and controlling the browser is one of them. In this particular article, we will see how to log in to the Facebook account using Python and the power of selenium.
Seleniumautomates and controls browsers and it's activity. We can code in our way to control browser tasks with the help of selenium. Primarily, it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can be automated as well. As you learn more it’s so much fun to see things happening automatically and saving time in doing useless tasks again and again. We use selenium here to open the site of our requirement (in this case Facebook) and there we inspect elements across email box, password box, and login button to find the id of them.
Selenium
getpass
Additional Requirement : geckodriver for firefox and
chromedriver for chrome
Complete Code:
See how such a concise piece of code can automate things for you.
Bonus:
We can also
enter the password without displaying it on screen
, for security purpose. For that we have to include one more module called
getpass
. Now with just one change in input statement of the password we can input password without displaying it on screen.
Getpass prompts the user for a password without echoing. Basically it lets you enter the password without showing it on the screen. Similarly you can also automate many other things like twitter login, tweeting, Facebook logout, and much more.
In case of any queries, post them below in the comments section. If you liked this article and want to see any more of the similar stuff, let me know in the comments section below.
This article is contributed by
Umang Ahuja
. If you like GeeksforGeeks and would like to contribute, you can also write an article using
write.geeksforgeeks.orgor mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.