質問編集履歴

2

ソースコードの追加、テンプレートの使用

2019/08/29 12:54

投稿

tomo_ishi
tomo_ishi

スコア14

test CHANGED
File without changes
test CHANGED
@@ -48,6 +48,44 @@
48
48
 
49
49
  ```Python3
50
50
 
51
+ #!/usr/bin/python
52
+
53
+ # coding: UTF-8
54
+
55
+
56
+
57
+ # ライブラリの読み込み
58
+
59
+ from selenium import webdriver
60
+
51
- ソースコー
61
+ # ライバの生成
62
+
63
+ # 問題なければFirefoxブラウザが自動的に起動する
64
+
65
+ driver = webdriver.Firefox()
66
+
67
+ # Firefox上でURLを指定してGETリクエスト
68
+
69
+ driver.get("http://www.google.co.jp/")
70
+
71
+
72
+
73
+ driver.find_element_by_name('q').send_keys("アヒルくわ")
74
+
75
+
76
+
77
+ driver.find_element_by_name("btnK").click()
78
+
79
+
80
+
81
+ #driver.save_screenshot('/home/ピクチャ/test.png')
82
+
83
+
84
+
85
+ # ドライバを閉じる
86
+
87
+ # 問題なければFirefoxも終了する
88
+
89
+ driver.close()
52
90
 
53
91
  ```

1

変更中

2019/08/29 12:54

投稿

tomo_ishi
tomo_ishi

スコア14

test CHANGED
File without changes
test CHANGED
@@ -1,14 +1,14 @@
1
+ ### 前提・実現したいこと
2
+
1
3
  python3のseleniumを使って、ブラウザを立ち上げ文字を入力し検索、スクリーンショットを保存するという動作をさせるプログラムを作っています。
2
4
 
3
5
  ブラウザを立ち上げ文字を入力するところまでは動いたのですが、検索をクリックする部分でエラーがでるのですが、どこが間違っているのでしょうか?
4
6
 
5
7
  ※OSはubuntuです。
6
8
 
9
+ ### 発生している問題・エラーメッセージ
7
10
 
8
-
9
- エラー文は下記のとおりです。
11
+ ```
10
-
11
-
12
12
 
13
13
  Traceback (most recent call last):
14
14
 
@@ -34,30 +34,20 @@
34
34
 
35
35
  selenium.common.exceptions.ElementNotInteractableException: Message: Element <input class="gNO89b" name="btnK" type="submit"> could not be scrolled into view
36
36
 
37
+ ```
37
38
 
38
39
 
39
- コードは下記のとおりです。
40
40
 
41
- Traceback (most recent call last):
42
41
 
43
- File "geckodriver1.py", line 14, in <module>
44
42
 
45
- driver.find_element_by_name("btnK").click()
46
43
 
47
- File "/home/ruccus/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
48
44
 
49
- self._execute(Command.CLICK_ELEMENT)
45
+ ### 該当のソースコード
50
46
 
51
- File "/home/ruccus/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
52
47
 
53
- return self._parent.execute(command, params)
54
48
 
55
- File "/home/ruccus/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
49
+ ```Python3
56
50
 
57
- self.error_handler.check_response(response)
51
+ ソースコード
58
52
 
59
- File "/home/ruccus/.local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
60
-
61
- raise exception_class(message, screen, stacktrace)
53
+ ```
62
-
63
- selenium.common.exceptions.ElementNotInteractableException: Message: Element <input class="gNO89b" name="btnK" type="submit"> could not be scrolled into view