実現したいこと
find_elementを動作させる
### 前提
chromeのselenium4でwebページを制御しようとしていますが、入り口の文字を入力するコントロールにたいして、
find_elementを動作させることができません。
発生している問題・エラーメッセージ
このエラーの意味がわかりません。
"using": by, "value": value})["value"]
c:\python>python test.py c:\python\test.py:3: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Chrome("c:/driver/chromedriver.exe") DevTools listening on ws://127.0.0.1:64234/devtools/browser/437d7bdd-b2d2-45b7-8dda-de9852ff051c [5204:2824:0325/145106.652:ERROR:page_load_metrics_update_dispatcher.cc(178)] Invalid first_paint (unset) for first_image_paint 1.955 s [5204:2824:0325/145106.652:ERROR:page_load_metrics_update_dispatcher.cc(178)] Invalid first_paint 2.037 s for first_image_paint 1.955 s Traceback (most recent call last): File "c:\python\test.py", line 5, in <module> email = driver.find_element(By.ID,"user-sign-in-email") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\qhtsi\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 830, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\qhtsi\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute [5204:2824:0325/145106.810:ERROR:page_load_metrics_update_dispatcher.cc(178)] Invalid first_paint 2.037 s for first_image_paint 1.955 s self.error_handler.check_response(response) File "C:\Users\qhtsi\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="user-sign-in-email"]"} (Session info: chrome=111.0.5563.111) Stacktrace: Backtrace:
該当のソースコード
python
1from selenium import webdriver 2from selenium.webdriver.common.by import By 3driver = webdriver.Chrome("c:/driver/chromedriver.exe") 4driver.get("https://eas.forexsb.com") 5email = driver.find_element(By.ID,"user-sign-in-email") 6email.send_keys("****@outlook.jp") 7elem_login_pw = driver.find_element(By.ID,"user-sign-in-password").send_keys("qACSqwvD") 8elem_login_email = driver.find_element(By.ID,"user-sign-in-submit").send_keys("keys.ENTER") 9
試したこと
ChromeのF12で、当該コントロール(文字列入力)を指定して、強調表示されたところ見る限り、IDの文字列は存在しているように見えます。この部分のカット&ペーストを試みましたが失敗しました。
補足情報(FW/ツールのバージョンなど)
python 3.11.1
selenium 4.8.2
どういった画面を出したいかにもよりますが、
Edgeでの環境でしたら、いけました。。。。
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Edge()
driver.get("https://eas.forexsb.com")
email = driver.find_element(By.ID,"user-sign-in-email")
email.send_keys("xxxx@〜")
elem_login_pw = driver.find_element(By.ID,"user-sign-in-password").send_keys("xxxxxxx")
elem_login_email = driver.find_element(By.ID,"user-sign-in-submit").send_keys("keys.ENTER")
ちなみに、コードを確認してみると、GoogleChromeを利用されてたようですが、WEBドライバーとブラウザのバージョンは同じになってますでしょうか?
Edgeでいけたので、もしかしたらWEBドライバーとブラウザのバージョンかな?とは思いましたが如何でしょう?

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