clicklist=[' 24 ', '25', '26']
Theclick=the random choice (clicklist)
& lt; A href="https://bbs.csdn.net/topics/#" & gt; 24
CodePudding user response:
Is to find, all of a traversal, a.t ext matching theclick click,
Href_items=DRV. Find_elements_by_tag_name (' a ')
For a in href_items:
Href_text=a.t ext
If href_text=theclick:
Print (' click 'theclick)
DRV. Get (a)
Break
CodePudding user response:
A regular match, open the corresponding linkCodePudding user response:
Driver. Find_element_by_xpath ('//a/text ()="{}"] '. The format (theclick). Click ()
CodePudding user response:
The selenium there are eight kinds of positioning methods, adopt the circumstances, such as find_element_by_xpath, find_element_by_class_name, etc