[PYTHON] I tried a simple RPA for login with selenium

Trigger

At the drinking party, I heard that a colleague at the company created a program that automatically inputs attendance at RPA. So I learned about the existence of selenium from his story and wanted to touch it myself.

I referred to the following site for the introduction.

[Super convenient] Summary of how to automatically operate the browser with Python and Selenium https://tanuhack.com/selenium/

The stumbling block was that I had to match the versions of Google Chrome and chromedriver. As of 12/3, the latest version of Google Chrome is 78, while The latest version of chromedriver was for beta 79. Therefore, it did not work with the latest version of chromedriver, so I downloaded it for 78 again.

What I made

I made a program that starts a browser and logs in to the AWS management console.

First, import the module.

aws.py


from selenium import webdriver

Next, I created two functions. send_id specifies the id of the input form in html and enters the key for that input form. id_click specifies the id of the submit button in the html and clicks there.

aws.py


#Enter the key in the id input form
def id_send(id,key):
    driver.find_element_by_id(id).send_keys(key)

#Click the id button
def id_click(id):
    driver.find_element_by_id(id).click()

Then specify the local chrome driver. The browser that opens is the AWS Management Console.

aws.py


#Specify a local chrome driver
driver = webdriver.Chrome('C:\\Users\\username\\Desktop\\selenium\\chromedriver')

#Open browser
driver.get('https://ap-northeast-1.console.aws.amazon.com/console/home?region=ap-northeast-1#')

In the opened browser, look for information on F12, input form ... (I have no knowledge of html, so I'm groping) ʻId =" resolved_inut "` is like that. キャプチャ1.png

Now, let's use the created function so that you can enter and send the account ID here. The account ID is actually a 12-digit number.

aws.py


#Input and send on the first screen
id_send('resolving_input','Account ID')
id_click('next_button')

Then the account ID is entered ... キャプチャ1.png

I jumped to the next page. キャプチャ1.png

In the same way, find the ID of the user name and password input form and put it in the program.

aws.py


id_send('username','username')
id_send('password','password')
id_click('signin_button')

And when it was sent successfully, I was able to log in. キャプチャ1.png

The above is this program.

Impressions / Future issues

This time it was a simple login like this, but if you learn more about html, css, javascript, I felt that the range of automation would expand. I want to deepen my knowledge while trying to create my own site.

Recommended Posts

I tried a simple RPA for login with selenium
A memorandum when I tried to get it automatically with selenium
I tried using Selenium with Headless chrome
I tried to make a periodical process with Selenium and Python
I tried simple image recognition with Jupyter
I tried to make a strange quote for Jojo with LSTM
I tried to log in to twitter automatically with selenium (RPA, scraping)
I made a simple blackjack with Python
I made a simple Bitcoin wallet with pycoin
I tried using a database (sqlite3) with kivy
I tried simple image processing with Google Colaboratory.
I tried to make a periodical process with CentOS7, Selenium, Python and Chrome
I tried to make a simple mail sending application with tkinter of Python
I tried to create a button for Slack with Raspberry Pi + Tact Switch
I tried to make a simple image recognition API with Fast API and Tensorflow
I made a window for Log output with Tkinter
I tried to draw a route map with Python
I tried to automatically generate a password with Python3
I tried collecting data from a website with Scrapy
I can't manipulate iframes in a page with Selenium
Since I am free, I make an "RPA tool" Extra edition
Make "RPA tool" because I have free time # 4 Selenium edition Text acquisition
Since I am free, I make "RPA tools" # 2 Development environment
I want to make an automation program!
I tried a simple RPA for login with selenium
I tried to create a reinforcement learning environment for Othello with Open AI gym
I tried fp-growth with python
I tried scraping with Python
I tried Learning-to-Rank with Elasticsearch!
I tried clustering with PyCaret
I tried gRPC with Python
I tried scraping with python
I tried to implement a volume moving average with Quantx
I made a simple typing game with tkinter in Python
I tried to automatically create a report with Markov chain
I made a simple book application with python + Flask ~ Introduction ~
I tried replacing the Windows 10 HDD with a smaller SSD
I tried to solve a combination optimization problem with Qiskit
I made a resource monitor for Raspberry Pi with a spreadsheet
I tried to get started with Hy ・ Define a class
I tried to sort a random FizzBuzz column with bubble sort.
I tried to create a bot for PES event notification
(For beginners) Try creating a simple web API with Django
I tried a stochastic simulation of a bingo game with Python
I tried to divide with a deep learning language model
I tried to make a simple text editor using PyQt
[5th] I tried to make a certain authenticator-like tool with python
I made a simple circuit with Python (AND, OR, NOR, etc.)
I touched PyAutoIt for a moment
Rubyist tried to make a simple API with Python + bottle + MySQL
I tried trimming efficiently with OpenCV
[2nd] I tried to make a certain authenticator-like tool with python
I tried summarizing sentences with summpy
I tried machine learning with liblinear
I tried web scraping with python.
[3rd] I tried to make a certain authenticator-like tool with python
I tried moving food with SinGAN
[Python] A memo that I tried to get started with asyncio
I made a fortune with Python.
I searched for a similar card of Hearthstone with Deep Learning
I tried to create a list of prime numbers with python
Creating a simple app with flask
[Pandas] I tried to analyze sales data with Python [For beginners]
[Python] I made an image viewer with a simple sorting function.
I tried implementing DeepPose with PyTorch