前提
Python 3.11.1
selenium 4.7.2
実現したいこと
変数keyname1に設定した値をテキストフィールドに入力したいのですが出来ません。
send_keysの使い方が誤っていますでしょうか。
入力対象はCLASS_NAMEと考えていますが、何かお気づきの方がいらっしゃいましたら
ご教授頂けないでしょうか。
宜しくお願い致します。
発生している問題・エラーメッセージ
Traceback (most recent call last): File "/selenium_input.py", line 81, in <module> driver.find_element(By.CLASS_NAME,"hoge-text-input").send_keys(keyname1) File "/webelement.py", line 233, in send_keys self._execute( File "/webelement.py", line 410, in _execute return self._parent.execute(command, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/webdriver.py", line 444, in execute self.error_handler.check_response(response) File "/errorhandler.py", line 249, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (Session info: chrome=108.0.5359.124)
該当のソースコード
Python
1from selenium import webdriver 2from selenium.webdriver.chrome.options import Options 3from selenium.webdriver.common.by import By 4 5options = Options() 6# ログインURL 7url = "https://hoge.co.jp/“ 8driver = webdriver.Chrome() 9 10# Chromeを起動 11driver.get(url) 12 13keyname1 = "*****" 14driver.find_element(By.CLASS_NAME,"hoge-text-input").send_keys(keyname1)
■対象のhtml
<div class="hoge-hoge-select"> <ul class="hoge-tag__wrapper"> </ul> <div class="hoge-hoge-select__filter"> <dl class="hoge-hoge-select__filter-head"> <dt class="hoge-hoge-select__filter-name"> <dd class="hoge-hoge-select__filter-input"> <div class="hoge-text-input__wrapper"> <input type="text" class="hoge-text-input" placeholder="key名を入力" value>
試したこと
変数keyname1に設定した値が入力されずエラーとなる
そこで14行目の代わりに下記の①〜⑤それぞれ試してみた
対象のclass名として下記の⑤つをそれぞれ試したが全て同様のエラーが発生
①driver.find_element(By.CLASS_NAME,"hoge-hoge-select__filter").send_keys(keyname1)
②driver.find_element(By.CLASS_NAME,"hoge-hoge-select__filter-head").send_keys(keyname1)
③driver.find_element(By.CLASS_NAME,"hoge-hoge-select__filter-name").send_keys(keyname1)
④driver.find_element(By.CLASS_NAME,"hoge-hoge-select__filter-input").send_keys(keyname1)
⑤driver.find_element(By.CLASS_NAME,"hoge-text-input__wrapper").send_keys(keyname1)
上記①〜⑤を試したが全て同様に下記のエラー
Traceback (most recent call last):
File "/selenium_input.py", line 81, in <module>
driver.find_element(By.CLASS_NAME,"①〜⑤のクラス名").send_keys(keyname1)
File "/webelement.py", line 233, in send_keys
self._execute(
File "/webelement.py", line 410, in _execute
return self._parent.execute(command, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/webdriver.py", line 444, in execute
self.error_handler.check_response(response)
File "/errorhandler.py", line 249, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=108.0.5359.124)
補足情報(FW/ツールのバージョンなど)

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/01/01 12:54
2023/01/01 12:57
2023/01/01 13:11 編集
2023/01/01 13:23
2023/01/01 13:43 編集
2023/01/01 13:46
2023/01/01 13:57 編集
2023/01/01 14:02
2023/01/01 14:31
2023/01/01 14:35
2023/01/02 08:12 編集
2023/01/02 04:27
2023/01/02 04:48 編集
2023/01/02 05:43
2023/01/02 08:14