Actually, filter would be even easier:

`for alert_id in self.q(".search-alert").filter(lambda elem: text in elem.text).attrs("id"):`