【发布时间】:2015-11-09 16:56:21
【问题描述】:
我收到以下错误:
“不允许使用复合类名”
在尝试访问 Web 元素时,元素的类名之间有空格。网页元素的页面来源如下。
driver.findElement(By.className("alert alert-success"));
<div class="alert alert-success" alert-dismissable"="" id="58417" style="display: none;">
<button type="button" class="close hide-panel close-icon-58417" data-dismiss="alert" aria-hidden="true" style="display: inline-block;">×</button><span id="caret-58417" class="notification-caret caret-58417"></span>
<div class="hide-panel close-icon-58417" id="58417" style="display: block;">
<span class="glyphicon glyphicon-ok-sign"></span><strong>Success</strong> KeyLinks Updated Successfully
<div class="notification-panel-body panel-body-58417">REST Invocation Success</div>
</div>
</div>
我尝试通过 CSS 路径查找元素,如下所示。但是这个元素是不可搜索的。
driver.findElement(By.cssSelector(".alert alert-success"));
这是given in the Link 的解决方法,但仍然没有成功。您的帮助将不胜感激。
【问题讨论】: