実現したいこと
selenium, undected_chromedriverを用いて外為オンラインのデモ口座にログインしたい
前提
Selenium, undetected_chromedriverを用いて外為オンライン(デモ)を動かすプログラムを書きたいです。
その前段階として、ログインを行う必要があるのですが、要素が取得できないエラーが発生しました。
発生している問題・エラーメッセージ
no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="demo_res_login"]/form/dl/dd[1]/input"}
(Session info: chrome=115.0.5790.102); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
該当のソースコード
Python3.11.4
Selenium4.10.0
undetected-chromedriver 3.5.0
import undetected_chromedriver as uc from selenium.webdriver.common.by import By import time # Google Chromeでページを立ち上げ url = 'https://www.gaitameonline.com/loginInline.jsp' browser = uc.Chrome() # open chrome time.sleep(1) browser.get(url) # URLにアクセス time.sleep(5) # ログインを行う username_input = browser.find_element(By.XPATH, '//*[@id="demo_res_login"]/form/dl/dd[1]/input') username_input.click() username_input.send_keys('自分のID') password_input = browser.find_element(By.XPATH, '//*[@id="demo_res_login"]/form/dl/dd[2]/input') password_input.click() password_input.send_keys('自分のパスワード') time.sleep(1)

回答1件
あなたの回答
tips
プレビュー