元素列表

发布于 2024-09-08 18:40:47 字数 312 浏览 0 评论 0原文

我在页面上有一些链接,例如:

123test.com/456
abc_test.com/sdfsd
abc_test.org

我必须获取 href 属性由 test 单词组成的所有元素。

我知道如何按给定编号单击此类链接:

selenium.click("//body/descendant::a[contains(@href,'test')][2]")

此代码将单击地址中包含“test”的第二个链接。但如何获得链接数呢?

I have some links at the page like:

123test.com/456
abc_test.com/sdfsd
abc_test.org

I have to get all elements which href attribute consists of test word.

I know how to click at such link by given number:

selenium.click("//body/descendant::a[contains(@href,'test')][2]")

This code will click at second link which has 'test' in address. But how to get that count of links?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

闻呓 2024-09-15 18:40:47

有功能:

get_xpath_count(self,xpath)
    """
    Returns the number of nodes that match the specified xpath, eg. "//table" would give
    the number of tables.

    'xpath' is the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you.
    """

There is function:

get_xpath_count(self,xpath)
    """
    Returns the number of nodes that match the specified xpath, eg. "//table" would give
    the number of tables.

    'xpath' is the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you.
    """
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文