0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

selenium よく使うコード

Posted at

ログイン処理

def login(driver: webdriver.Chrome, username: str, password: str) -> bool:
    """
    認証情報を元にログインを実行する。
    以下の情報を返す。
    - 成功: True
    - 失敗: False
    """
    wait = WebDriverWait(driver=driver, timeout=30)

    driver.get('URL')
    wait.until(EC.presence_of_all_elements_located)

    id_form = driver.find_element_by_name('user')
    id_form.send_keys(username)

    pw_form = driver.find_element_by_name('password')
    pw_form.send_keys(password)

    pw_form.send_keys(Keys.RETURN)

    wait.until(EC.presence_of_all_elements_located)

    success_url = 'URL'

    if driver.current_url == success_url:
        return True
    else:
        return False
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?