【问题标题】:Uable to access element in dropdown using xpath无法使用 xpath 访问下拉列表中的元素
【发布时间】:2022-08-03 00:12:24
【问题描述】:

我有一个带有时区下拉列表的网页,我想在其中访问选项

HTML如下:

            <li>
              <div id=\"ember2503\" class=\"artdeco-dropdown__item artdeco-dropdown__item--is-dropdown ember-view\" tabindex=\"0\"><!---->
                (UTC-11:00) Midway Island, Samoa
              </div>
            </li>

我想使用 text 属性选择选项。 使用 text 属性将允许我通过变量 \'capital\'s name\' 来访问该选项。

我尝试使用 text() 属性访问它,但它不可见。 这是 XPath:

//div[contains(text(),\'Midway\')]

此 XPath 不工作。有什么办法可以访问这个吗?

    标签: python html xpath


    【解决方案1】:

    试试这个

    //div[contains(.,'Midway')]
    

    【讨论】:

    • 哇!你只是在一分钟内回复!谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-15
    • 2016-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-16
    相关资源
    最近更新 更多