質問編集履歴
1
ついか
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,4 +2,41 @@
|
|
2
2
|
その際のログイン画面のところでエラーが出てきているのでわかる方に教えていただきたいです。
|
3
3
|
|
4
4
|
x_pathを用いてログイン画面の移動やパスワードの入力を自動で行えるプログラミングを組んでいるのですがその際にほかサイトにて調べたとおりにx_pathを調べてコピペしていて期待通りなら動くはずなのですが、うまくいきません。
|
5
|
-
下記にてログイン部分のコード、ならびにエラー内容を記しますのでわかる方がいらっしゃいましたらご教ください。
|
5
|
+
下記にてログイン部分のコード、ならびにエラー内容を記しますのでわかる方がいらっしゃいましたらご教授ください。
|
6
|
+
|
7
|
+
コード
|
8
|
+
def Login(self):
|
9
|
+
url = "https://twitter.com/"
|
10
|
+
self.driver.get(url)
|
11
|
+
|
12
|
+
print(self.driver.current_url)
|
13
|
+
|
14
|
+
self.driver.find_element_by_xpath('//*[@id="doc"]/div/div[1]/div[1]/div[2]/div[2]/div/a[2]').click()
|
15
|
+
time.sleep(5)
|
16
|
+
id = self.driver.find_element_by_xpath('//*[@id="page-container"]/div/div[1]/form/fieldset/div[1]/input')
|
17
|
+
id.send_keys(self.yourId)
|
18
|
+
time.sleep(5)
|
19
|
+
password = self.driver.find_element_by_xpath('//*[@id="page-container"]/div/div[1]/form/fieldset/div[2]/input')
|
20
|
+
password.send_keys(self.yourPassWord)
|
21
|
+
time.sleep(5)
|
22
|
+
print(self.driver.current_url)
|
23
|
+
self.driver.find_element_by_xpath('//*[@id="page-container"]/div/div[1]/form/div[2]/button').click()
|
24
|
+
|
25
|
+
エラー
|
26
|
+
DevTools listening on ws://127.0.0.1:53968/devtools/browser/23298def-2b97-492d-b4b6-156d59393a66
|
27
|
+
https://twitter.com/
|
28
|
+
Traceback (most recent call last):
|
29
|
+
File "AutoTweet.py", line 153, in <module>
|
30
|
+
tweet1.Login()
|
31
|
+
File "AutoTweet.py", line 29, in Login
|
32
|
+
self.driver.find_element_by_xpath('//*[@id="react-root"]/div/div/div/main/div/div/div/div[1]/div/a[2]').click()
|
33
|
+
File "C:\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
|
34
|
+
return self.find_element(by=By.XPATH, value=xpath)
|
35
|
+
File "C:\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
|
36
|
+
return self.execute(Command.FIND_ELEMENT, {
|
37
|
+
File "C:\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
|
38
|
+
self.error_handler.check_response(response)
|
39
|
+
File "C:\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
|
40
|
+
raise exception_class(message, screen, stacktrace)
|
41
|
+
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="react-root"]/div/div/div/main/div/div/div/div[1]/div/a[2]"}
|
42
|
+
(Session info: chrome=80.0.3987.100)
|