【发布时间】:2019-07-20 19:02:20
【问题描述】:
我试图在 url http://gridworlds-multiplayer.org/ 中使用类名“rps-wrapper”访问 div 内的“事件”,但是当我使用该函数时出现错误。
<div class="rps-wrapper">
<ul id="events"></ul>
<div class="controls">
<div class="chat-wrapper">
<form id="chat-form">
<input id="chat" autocomplete="off" title="chat"/>
<button id="say">Say</button>
</form>
</div>
</div>
</div>
<script src="/socket.io/socket.io.js"></script>
<script src="src/client.js"></script>
</body>
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('*the site is here*')
rps_wrapper = driver.find_element_by_class_name('rps-wrapper')
应该得到类名为rps-wrapper的div,但输出错误elenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".rps-wrapper"}
(Session info: chrome=75.0.3770.142)
【问题讨论】:
-
你能检查一下是否有 iframe 吗?
-
可以分享网址吗
标签: python selenium xpath css-selectors webdriverwait