前提・実現したいこと
python3のseleniumを使って、ブラウザを立ち上げ文字を入力し検索、スクリーンショットを保存するという動作をさせるプログラムを作っています。
ブラウザを立ち上げ文字を入力するところまでは動いたのですが、検索をクリックする部分でエラーがでるのですが、どこが間違っているのでしょうか?
※OSはubuntuです。
発生している問題・エラーメッセージ
Traceback (most recent call last): File "geckodriver1.py", line 14, in <module> driver.find_element_by_name("btnK").click() File "/home/ruccus/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click self._execute(Command.CLICK_ELEMENT) File "/home/ruccus/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute return self._parent.execute(command, params) File "/home/ruccus/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/ruccus/.local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: Element <input class="gNO89b" name="btnK" type="submit"> could not be scrolled into view
該当のソースコード
Python3
1#!/usr/bin/python 2# coding: UTF-8 3 4# ライブラリの読み込み 5from selenium import webdriver 6# ドライバの生成 7# 問題なければFirefoxブラウザが自動的に起動する 8driver = webdriver.Firefox() 9# Firefox上でURLを指定してGETリクエスト 10driver.get("http://www.google.co.jp/") 11 12driver.find_element_by_name('q').send_keys("アヒルくわ") 13 14driver.find_element_by_name("btnK").click() 15 16#driver.save_screenshot('/home/ピクチャ/test.png') 17 18# ドライバを閉じる 19# 問題なければFirefoxも終了する 20driver.close()