質問編集履歴
3
求めていた回答が頂けたので秋絵師
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Seleniumで非同期に生成されるいいねボタンをクリックしたい
|
test
CHANGED
@@ -1 +1,59 @@
|
|
1
|
+
#やりたいこと
|
2
|
+
|
3
|
+
Seleniumで非同期に生成されるいいねボタンをクリックしたい
|
4
|
+
|
5
|
+
# 詰まっていること
|
6
|
+
|
7
|
+
いいねボタンの要素を取得するところまでは、動作しているのですが、
|
8
|
+
|
9
|
+
その要素をクリックするアクションを指定すると要素が見つからないとエラーが発生します。
|
10
|
+
|
11
|
+
要素は取得できているので、あとはクリックだけなのですが、
|
12
|
+
|
13
|
+
非同期の要素をクリックするために必要なSeleniumの設定があるのでしょうか。
|
14
|
+
|
15
|
+
知見がある方お力添えいただければ幸いです。
|
16
|
+
|
17
|
+
よろしくお願いします!
|
18
|
+
|
19
|
+
```
|
20
|
+
|
21
|
+
element not visible (Selenium::WebDriver::Error::ElementNotVisibleError)
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
#環境
|
26
|
+
|
27
|
+
Mac ローカル
|
28
|
+
|
29
|
+
gem 'selenium-webdriver'
|
30
|
+
|
31
|
+
```Ruby
|
32
|
+
|
33
|
+
require 'selenium-webdriver'
|
34
|
+
|
35
|
+
article_url = "https://qiita.com/tomerun/items/9cb81d7a98150ff22f53"
|
36
|
+
|
37
|
+
driver = Selenium::WebDriver.for :chrome
|
38
|
+
|
39
|
+
/* ここで qiita ログインする */
|
40
|
+
|
41
|
+
driver.manage.timeouts.implicit_wait = 30
|
42
|
+
|
43
|
+
driver.navigate.to target_url
|
44
|
+
|
45
|
+
#出力されるもの <Selenium::WebDriver::Element:0x007fc9ca84e720>
|
46
|
+
|
1
|
-
|
47
|
+
puts x = driver.find_elements(:class => "likable")[0].find_element(:xpath, 'button')
|
48
|
+
|
49
|
+
#出力されるもの 'いいね'
|
50
|
+
|
51
|
+
puts y = driver.find_elements(:class => "likable")[0].find_elements(:xpath, 'button')[0].attribute("data-tip") #
|
52
|
+
|
53
|
+
#エラーメッセージ element not visible
|
54
|
+
|
55
|
+
x.click
|
56
|
+
|
57
|
+
driver.quit
|
58
|
+
|
59
|
+
```
|
2
質問をやめる
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
testaaaaaaaaaaaa
|
test
CHANGED
@@ -1,93 +1 @@
|
|
1
|
-
#やりたいこと
|
2
|
-
|
3
|
-
Seleniumで非同期に生成されるいいねボタンをクリックしたい
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# 詰まっていること
|
8
|
-
|
9
|
-
いいねボタンの要素を取得するところまでは、動作しているのですが、
|
10
|
-
|
11
|
-
その要素をクリックするアクションを指定すると要素が見つからないとエラーが発生します。
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
要素は取得できているので、あとはクリックだけなのですが、
|
18
|
-
|
19
|
-
非同期の要素をクリックするために必要なSeleniumの設定があるのでしょうか。
|
20
|
-
|
21
|
-
知見がある方お力添えいただければ幸いです。
|
22
|
-
|
23
|
-
よろしくお願いします!
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
```
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
element not visible (Selenium::WebDriver::Error::ElementNotVisibleError)
|
34
|
-
|
35
|
-
```
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
#環境
|
44
|
-
|
45
|
-
Mac ローカル
|
46
|
-
|
47
|
-
gem 'selenium-webdriver'
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
```Ruby
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
require 'selenium-webdriver'
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
article_url = "https://qiita.com/tomerun/items/9cb81d7a98150ff22f53"
|
62
|
-
|
63
|
-
driver = Selenium::WebDriver.for :chrome
|
64
|
-
|
65
|
-
/* ここで qiita ログインする */
|
66
|
-
|
67
|
-
driver.manage.timeouts.implicit_wait = 30
|
68
|
-
|
69
|
-
driver.navigate.to target_url
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
#出力されるもの <Selenium::WebDriver::Element:0x007fc9ca84e720>
|
74
|
-
|
75
|
-
|
1
|
+
ああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
#出力されるもの 'いいね'
|
80
|
-
|
81
|
-
puts y = driver.find_elements(:class => "likable")[0].find_elements(:xpath, 'button')[0].attribute("data-tip") #
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
#エラーメッセージ element not visible
|
86
|
-
|
87
|
-
x.click
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
driver.quit
|
92
|
-
|
93
|
-
```
|
1
タイトルをわかりやすく
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Seleniumでいいねボタンをクリックしたい
|
1
|
+
Seleniumで非同期に生成されるいいねボタンをクリックしたい
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#やりたいこと
|
2
2
|
|
3
|
-
非同期
|
3
|
+
Seleniumで非同期に生成されるいいねボタンをクリックしたい
|
4
4
|
|
5
5
|
|
6
6
|
|