Xpath 要素清单
我在页面上有一些链接,如:Xpath 要素清单,xpath,selenium,count,element,Xpath,Selenium,Count,Element,我在页面上有一些链接,如: 123test.com/456 abc_test.com/sdfsd abc_test.org 我必须获取href属性由testword组成的所有元素 我知道如何按给定的数字单击此链接: selenium.click("//body/descendant::a[contains(@href,'test')][2]") 此代码将在地址中有“test”的第二个链接处单击。但是如何获得链接数呢?有以下功能: get_xpath_count(self,xpath)
123test.com/456
abc_test.com/sdfsd
abc_test.org
我必须获取href属性由testword组成的所有元素
我知道如何按给定的数字单击此链接:
selenium.click("//body/descendant::a[contains(@href,'test')][2]")
此代码将在地址中有“test”的第二个链接处单击。但是如何获得链接数呢?有以下功能:
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.
"""