更新时间:2023-02-23 18:11:07
你正在使用,所以从个人偏好我假设Python。其他语言不应该有什么不同。
is_element_present
函数可以用于此。从Selenium来源:
def is_element_present(self,locator):
验证指定的元素在页面上的某处
'locator'是一个元素定位器
return self.get_boolean(isElementPresent,[locator,]
对于定位器,您可以使用css = a [href * ='rid']
。
I have a HTML tags:
<a href="rid=7059"> abc </a>
<a href="pid=8059"> fgh </a>
<a href="cid=9059"> cxq </a>
HOw do I check if a particular tag exists with the href
attribute containing rid
(First tag in the above example)
get_attribute()
gets the value of a specified attribute but how do i check when in a page any such tag exists whose attribute value is rid
?
Thanks for the help.
You didn't mention the language you are using, so from personal preference I'm assuming Python. Other languages shouldn't really differ, though.
The is_element_present
function can be used for this. From the Selenium source:
def is_element_present(self,locator):
"""
Verifies that the specified element is somewhere on the page.
'locator' is an element locator
"""
return self.get_boolean("isElementPresent", [locator,]
For the locator you could use something along the lines of "css=a[href*='rid']"
.