开发者

List of elements

开发者 https://www.devze.com 2023-01-07 03:35 出处:网络
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 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 whic开发者_StackOverflow社区h has 'test' in address. But how to get that count of links?


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.
    """
0

精彩评论

暂无评论...
验证码 换一张
取 消