質問編集履歴
2
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
遷移できない時はchromeを閉じさせたいのですが、どうすれば良いでしょうか?
|
4
4
|
|
5
5
|
|
6
|
-
|
7
|
-
# -*- coding: utf-8 -*-
|
8
6
|
|
9
7
|
import time
|
10
8
|
|
1
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,103 @@
|
|
1
1
|
chromeでselenium(python)を使っているのですが、chromeのトップページから遷移できずにずっと待機していることがあります。(タスクスゲシューラで起動しています。)
|
2
2
|
|
3
3
|
遷移できない時はchromeを閉じさせたいのですが、どうすれば良いでしょうか?
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
# -*- coding: utf-8 -*-
|
8
|
+
|
9
|
+
import time
|
10
|
+
|
11
|
+
from selenium.webdriver.chrome.options import Options
|
12
|
+
|
13
|
+
from selenium import webdriver
|
14
|
+
|
15
|
+
from selenium.webdriver.common.keys import Keys
|
16
|
+
|
17
|
+
from selenium.webdriver.chrome.options import Options
|
18
|
+
|
19
|
+
from selenium.webdriver.support.select import Select
|
20
|
+
|
21
|
+
from selenium.webdriver.common.by import By
|
22
|
+
|
23
|
+
from selenium.webdriver.common.keys import Keys
|
24
|
+
|
25
|
+
from selenium.webdriver.common.alert import Alert
|
26
|
+
|
27
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
28
|
+
|
29
|
+
from selenium.webdriver.support import expected_conditions as EC
|
30
|
+
|
31
|
+
from selenium.common.exceptions import TimeoutException
|
32
|
+
|
33
|
+
from selenium.webdriver.common.action_chains import ActionChains
|
34
|
+
|
35
|
+
from selenium.webdriver.common.by import By
|
36
|
+
|
37
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
38
|
+
|
39
|
+
from selenium.webdriver.support import expected_conditions
|
40
|
+
|
41
|
+
from pathlib import Path
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
options = Options()
|
46
|
+
|
47
|
+
options.add_argument('--disable-gpu');
|
48
|
+
|
49
|
+
options.add_argument('--disable-extensions');
|
50
|
+
|
51
|
+
options.add_argument('--proxy-server="direct://"');
|
52
|
+
|
53
|
+
options.add_argument('--proxy-bypass-list=*');
|
54
|
+
|
55
|
+
options.add_argument('--start-maximized');
|
56
|
+
|
57
|
+
options = webdriver.ChromeOptions()
|
58
|
+
|
59
|
+
options.add_argument('--user-data-dir=C:\Users\abcde\AppData\Local\Google\Chrome\User Data')
|
60
|
+
|
61
|
+
options.add_argument('--profile-directory=Profile 7')
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
driver = webdriver.Chrome(options=options)
|
66
|
+
|
67
|
+
driver.maximize_window()
|
68
|
+
|
69
|
+
driver.get("https://www.abcdefg.co.jp")
|
70
|
+
|
71
|
+
time.sleep(25)
|
72
|
+
|
73
|
+
actions = ActionChains(driver)
|
74
|
+
|
75
|
+
time.sleep(25)
|
76
|
+
|
77
|
+
driver.find_element_by_name('ACT_login').click()
|
78
|
+
|
79
|
+
time.sleep(25)
|
80
|
+
|
81
|
+
driver.find_element_by_xpath("//*[@id='nation09P']/ul/li[5]/a/img").click();
|
82
|
+
|
83
|
+
time.sleep(25)
|
84
|
+
|
85
|
+
driver.find_element_by_xpath("//*[@id='MAIN01-INNER-R']/div[8]/div/div/div/div/div/div/div[0]/div[9]/a").click();
|
86
|
+
|
87
|
+
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
|
88
|
+
|
89
|
+
time.sleep(25)
|
90
|
+
|
91
|
+
iframe = driver.find_element_by_xpath("//*[@id='root']/div/div/div[4]/div[0]/div[1]/div").click();
|
92
|
+
|
93
|
+
time.sleep(15)
|
94
|
+
|
95
|
+
driver.switch_to.default_content()
|
96
|
+
|
97
|
+
time.sleep(5)
|
98
|
+
|
99
|
+
driver.find_element_by_xpath("//*[@id='logoutM']/a/img").click();
|
100
|
+
|
101
|
+
driver.close()
|
102
|
+
|
103
|
+
driver.quit()
|