i'm trying click following link using selenium.
<div id="record_2" class="search-results-item"> <a hasautosubmit="true" oncontextmenu="javascript:return isallowedrightclick(this);" class="smallv110" href="#;cacheurlfromrightclick=no"></a> </div>
which record click not known before code executed. record_2 has multiple children, , 1 included 1 want click. link edited sake of privacy. tried name record variable, doesn't work.
driver.find_element_by_css_selector("css=div#"record_%s" % (name).smallv110")
i'm complete newbie selenium couldn't figure out way sort out. appreciate help. thanks!
note not selenium ide , don't need css=
@ beginning of selector.
there multiple ways locate link element, e.g.:
driver.find_element_by_css_selector(".search-results-item a.smallv110") driver.find_element_by_css_selector("[id^=record] a.smallv110") # id starts "record"
if know id
value beforehand:
id_i_know = 2 driver.find_element_by_css_selector("[id=record_%d] a.smallv110" % id_i_know)
you don't have have smallv110
class attribute check - i've added increase chances of not matching other a
elements inside div
(not sure are, have not posted entire html).