views:

48

answers:

1

Hello, 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?

A: 

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