java - 将 WebElement 的属性值存储在 Selenium Webdriver 中

标签 java selenium webdriver html-lists

我有一个动态填充的 UL,每次单击“操作”按钮时,ID 也会动态生成;有没有办法读取

的标签
<div class="class">
 <ul id="dynamically generated">
  <li class="li_class">
  <li class="li_class">
  <li class="li_class">
  <li class="li_class">
  <li class="li_class">
 </ul>
</div>

最佳答案

既然你没有提到任何语言,我就选择JAVA syntax :

// String object 'field_value' is created
String fieldValue;  
// The field value is retrieved by the getAttribute("id") Selenium WebDriver predefined method and assigned to the String object.
fieldValue = _driver.findElement(By.ById("dynamically generated")).getAttribute("id")  

它将获取元素的给定属性的值。将返回当前值,即使该值在页面加载后已被修改。

关于java - 将 WebElement 的属性值存储在 Selenium Webdriver 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32180185/

相关文章:

python - 获取与 selenium (xpath) 的链接并单击 (python 2.7)

javascript - 无法在禁用和启用状态下断言双操作按钮

java - Selenium Web 驱动程序测试 Web 元素已更新

java - Spring MVC 3.2.8 : Create a new FileSystemXmlApplicationContext and loading the definitions from the given XML files

java - 在java中使用父引用类型访问变量

java - Webdriver:Firefox 驱动程序不再工作

python - 默认调用父构造函数?

java - 如何覆盖JPA实体的@Table.catalog值?

java - Mongodb聚合框架中是否有地板功能?

java - 防止在 selenium webdriver 测试中加载外部内容