gpt4 book ai didi

firefox - 如何使用 Selenium WebDriver 读取 DIV 元素的 id 值?

转载 作者:行者123 更新时间:2023-12-02 22:22:19 25 4
gpt4 key购买 nike

<div id="ctl00_ContentHolder_vs_ValidationSummary" class="errorblock">
<p><strong>The following errors were found:</strong></p>
<ul><input type="hidden" Name="SummaryErrorCmsIds" Value="E024|E012|E014" />
<li>Please select a title.</li>
<li>Please key in your first name.</li>
<li>Please key in your last name.</li>
</ul>
</div>

here is my snippet for example. i want to get the value of ID i.e., ct100_contentHolder_vs_ValidationSummary. using selenium web driver. h

最佳答案

你可以试试这个:

String id=driver.findElementByXpath("//div[@class='errorblock']").getAttribute("id"));

但在这种情况下,该部门的类应该是唯一的。

关于firefox - 如何使用 Selenium WebDriver 读取 DIV 元素的 id 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13506438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com