【发布时间】:2016-06-15 10:17:31
【问题描述】:
我正在尝试使用 ID 和标记名从网页中捕获产品描述,但是当我打印它时,它显示为空白。但是我认为我使用了正确的定位器来定位元素。
页面来源
<div id="item-description-block" class="layout-container layout-container-background clearfix">
<h2>About this item</h2>
<div id="social_share" class="details-row" onclick="javascript:clickPDP('Share','123070751499');">
<div class="details-row clear_both">
<div id="inspirational_copy">
<p>The big plus: Our new formula now helps strengthen skin's own moisture barrier. More moisture stays in. Skin feels soft, springy. Has a healthy-looking glow.</p>
</div>
Web 驱动程序代码
driver.get("http://www.debenhams.com/webapp/wcs/stores/servlet/prod_10701_10001_123070751499_-1");
WebElement description =driver.findElement(By.id("inspirational_copy").tagName("p"));
String description1 = description.getText();
【问题讨论】:
-
我想要段落中的字符串 - 最大的优点:我们的新配方现在有助于加强皮肤自身的水分屏障。更多的水分留在里面。皮肤感觉柔软,有弹性。拥有健康的光泽。
-
感谢@RemcoW,我试过了,但与此段落相同的结果在输出中仍然不可见。您认为可以提供帮助的任何其他方式。
-
我已经编辑了我的答案,请看一下。欢迎消息阻止我收到文本,这也可能是您的问题。