【问题标题】:Get list of HTML attributes given HTML element id获取给定 HTML 元素 id 的 HTML 属性列表
【发布时间】:2018-05-31 22:39:05
【问题描述】:

我对 XPath 并不十分熟悉,我需要实现以下目标:

假设我获得了 html 标签 id,并且我需要接收具有给定 id 的 html 元素的每个属性,除了 id,例如:

作为输入,我得到了id="test",

作为一个输出,我需要得到类似的东西:

"Key" = "some-randmom-attribute"= 
"Value"="value-of-random-attribute";

"Key" = "some-randmom-attribute2"= 
"Value"="value-of-random-attribute2";

我需要的是:

允许获取具有给定 id 的 html 标记的所有属性的查询,

干杯

【问题讨论】:

标签: java xml xpath


【解决方案1】:

假设您使用 Java 和 Selenium Xpath 选择器:

WebElement target = driver.findElement(By.xpath("//*[@id='someID']"));

然后按照此处创建的解决方案进行操作:

Selenium webdriver get all the data attributes of an element

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-11
    • 1970-01-01
    • 2021-04-17
    • 1970-01-01
    • 1970-01-01
    • 2014-03-01
    • 2011-11-30
    • 1970-01-01
    相关资源
    最近更新 更多