Help us understand the problem. What is going on with this article?

python × seleniumでID/PASS入力必要な画面に自動ログインしてみた

More than 1 year has passed since last update.

はじめに

python × seleniumでID/PASS入力必要な画面に自動ログインを試した際の自分的なメモとなります。

参考にさせて頂いた記事

http://blog2.tbshiki.com/entry/pythonstudy004#Selenium用のchromedriverを読み込ませる

コード

login.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

options = Options()
options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'

driver = webdriver.Chrome(chrome_options=options)
driver.get('対象のURL')

# ID/PASSを入力
id = driver.find_element_by_id("ユーザID入力フィールドの要素")
id.send_keys("実際のID")
password = driver.find_element_by_id("パスワード入力フィールドの要素")
password.send_keys("実際のPASS")

time.sleep(1)

# ログインボタンをクリック
login_button = driver.find_element_by_name("ログインボタンの要素")
login_button.click()

# サイト内で他の画面に遷移させたければ
driver.get('画面遷移させたいURL')
shota-nekoneko
猫大好きおっさん
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした