環境
CentOS7
python 3.6.3
実現したいこと
あるサイトの管理画面にログイン後、"レポート"というリンクをクリックしたい
find_element_by_link_textでなぜクリックできないのかご教示お願い致します
python
1from selenium import webdriver 2import pandas as pd 3import requests 4from bs4 import BeautifulSoup 5 6 7driver = webdriver.PhantomJS() 8driver.set_window_size(1024, 768) 9..... 10driver.find_element_by_link_text(u"レポート").click() 11 12エラーメッセージ 13Traceback (most recent call last): 14 File "<stdin>", line 1, in <module> 15 File "/root/.pyenv/versions/3.6.3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 392, in find_element_by_link_text 16 return self.find_element(by=By.LINK_TEXT, value=link_text) 17 File "/root/.pyenv/versions/3.6.3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 858, in find_element 18 'value': value})['value'] 19 File "/root/.pyenv/versions/3.6.3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 311, in execute 20 self.error_handler.check_response(response) 21 File "/root/.pyenv/versions/3.6.3/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response 22 raise exception_class(message, screen, stacktrace) 23selenium.common.exceptions.NoSuchElementException: Message: {"errorMessage":"Unable to find element with link text 'レポート'","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"112","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:60297","User-Agent":"Python http auth"},"httpVersion":"1.1","method":"POST","post":"{\"using\": \"link text\", \"value\": \"\u30ec\u30dd\u30fc\u30c8\", \"sessionId\": \"43daa7d0-f44a-11e7-9bac-633dbf5ee480\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/43daa7d0-f44a-11e7-9bac-633dbf5ee480/element"}} 24Screenshot: available via screen
ソース
html
1<li><a href="/a/reports/monthly">レポート</a></li>