質問編集履歴
7
誤字
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
seleniumでexecute_scriptを使って高速入力がしたい。
|
1
|
+
おseleniumでexecute_scriptを使って高速入力がしたい。
|
body
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
option.add_argument('--incognito')
|
13
13
|
driver = webdriver.Chrome(executable_path="chromedriverのパス",options=option)
|
14
14
|
|
15
|
-
driver.get("http://
|
15
|
+
driver.get("http://mymemo.top/")
|
16
16
|
time.sleep(3)
|
17
17
|
|
18
18
|
with open(r'開きたいテキストのパス',encoding='UTF-8') as s:
|
6
誤字
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
seleniumでexecute_scriptを使って高速入力がしたい。
|
body
CHANGED
File without changes
|
5
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,15 +12,16 @@
|
|
12
12
|
option.add_argument('--incognito')
|
13
13
|
driver = webdriver.Chrome(executable_path="chromedriverのパス",options=option)
|
14
14
|
|
15
|
-
driver.get("
|
15
|
+
driver.get("http://www.drpartners.jp/tools/browser-memocho.htm")
|
16
16
|
time.sleep(3)
|
17
17
|
|
18
18
|
with open(r'開きたいテキストのパス',encoding='UTF-8') as s:
|
19
19
|
v = s.read()
|
20
|
-
driver.execute_script('document.getElementsByName("
|
20
|
+
driver.execute_script('document.getElementsByName("??").value="%s";' %v )
|
21
21
|
```
|
22
|
+
**[フォルダ内テキストの例]**
|
23
|
+

|
22
24
|
|
23
|
-
|
24
25
|
**"""テキストボックスに文字列を高速入力するコード"""**
|
25
26
|
w.execute_script('document.getElementById("id属性").value="%s";' % text)
|
26
27
|
w.execute_script('document.getElementsByName("name属性")[0].value="%s";' % text)
|
4
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,12 +10,12 @@
|
|
10
10
|
|
11
11
|
option = Options()
|
12
12
|
option.add_argument('--incognito')
|
13
|
-
driver = webdriver.Chrome(executable_path="
|
13
|
+
driver = webdriver.Chrome(executable_path="chromedriverのパス",options=option)
|
14
14
|
|
15
15
|
driver.get("https://www.google.com/?hl=ja")
|
16
16
|
time.sleep(3)
|
17
17
|
|
18
|
-
with open(r'
|
18
|
+
with open(r'開きたいテキストのパス',encoding='UTF-8') as s:
|
19
19
|
v = s.read()
|
20
20
|
driver.execute_script('document.getElementsByName("q").value="%s";' %v )
|
21
21
|
```
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
2
修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
seleniumでexecute_scriptを使って高速入力がしたい。
|
1
|
+
i seleniumでexecute_scriptを使って高速入力がしたい。
|
body
CHANGED
@@ -1,7 +1,20 @@
|
|
1
1
|
ブラウザでの入力を自動化するためにpython&seleniumを使っています。
|
2
2
|
-**問題1**-
|
3
|
-
send.key()だと入力が遅いため、execute_script(最下部のコード)を使ってフォルダ内に存在するテキストをテキストエリアに高速入力できるようにしたいが、
|
3
|
+
send.key()だと入力が遅いため、execute_script(最下部のコード)を使ってフォルダ内に存在するテキストをテキストエリアに高速入力できるようにしたいが、テキストがテキストエリアに入力されないのでご教授いただけると幸いです。
|
4
4
|
```python
|
5
|
+
import time
|
6
|
+
import random
|
7
|
+
from selenium import webdriver
|
8
|
+
from selenium.webdriver.common.keys import Keys
|
9
|
+
from selenium.webdriver.chrome.options import Options
|
10
|
+
|
11
|
+
option = Options()
|
12
|
+
option.add_argument('--incognito')
|
13
|
+
driver = webdriver.Chrome(executable_path="/ex/ex/ex/ex/ex/chromedriver",options=option)
|
14
|
+
|
15
|
+
driver.get("https://www.google.com/?hl=ja")
|
16
|
+
time.sleep(3)
|
17
|
+
|
5
18
|
with open(r'/ex/ex/ex/ex/example.txt',encoding='UTF-8') as s:
|
6
19
|
v = s.read()
|
7
20
|
driver.execute_script('document.getElementsByName("q").value="%s";' %v )
|
1
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,4 +11,5 @@
|
|
11
11
|
**"""テキストボックスに文字列を高速入力するコード"""**
|
12
12
|
w.execute_script('document.getElementById("id属性").value="%s";' % text)
|
13
13
|
w.execute_script('document.getElementsByName("name属性")[0].value="%s";' % text)
|
14
|
-
w.execute_script('document.getElementsByClassName("class名(class属性)")[0].value="%s";' % text)
|
14
|
+
w.execute_script('document.getElementsByClassName("class名(class属性)")[0].value="%s";' % text)
|
15
|
+
# 変数の説明 w: ウェブドライバー text: 入力するテキスト
|