我有下面的代码是一个元素上点击,弹出一个屏幕和它硒化合物类名称不允许
el1 = driver.find_element_by_id("keyDev-A")
el1.click()
el2 = driver.find_element_by_class_name("content")
print(el2.text)
但是复制的文本,当我试图让selenium
点击该按钮与
el3 = driver.find_element(By.CLASS_NAME, "action-btn cancel alert-display")
el3.click()
该弹出式内它产生的错误信息:invalid selector: Compound class names not permitted
这是我试图让的HTML 10点击。 Close
按钮。
<div class="nav">
<span class="action-btn confirm prompt-display">Confirm</span>
<span class="action-btn cancel prompt-display">Cancel</span>
<span class="action-btn cancel alert-display">Close</span>
</div>
我应该怎么写el3
才能点击关闭按钮?
你见过http://stackoverflow.com/questions/10658907/selenium-python-find-element-by -class-name-stopped-working-from-v-2-2-to-2-21?它可能有帮助。 – Leon
Selenium不支持具有**复合类**的'BY.CLASS_NAME' ..您需要在这里使用'cssSelector'或'XPath'来查找'el3' ... –
[如何避免复合类名称页面对象错误?](http://stackoverflow.com/questions/17808521/how-to-avoid-compound-class-name-error-in-page-object) – Liam