Answer the question
In order to leave comments, you need to log in
Selenium. I use find_elements and get_atribute, but how can I do it in one request so that I don’t get a not attached error?
I do it like this:
dialogs = [i.get_attribute('data-list-id') for i in
self.find_elements_by_xpath('//ul[@id="im_dialogs"]/li[contains(@class, "nim-dialog_unread ")]')]
Answer the question
In order to leave comments, you need to log in
About not-attached - I suspect you didn't wait for the page to fully load.
In general, XPath has a choice of attribute values:
//ul[@id="im_dialogs"]/li[contains(@class, "nim-dialog_unread ")]/@data-list-id
string(//ul[@id="im_dialogs"]/li[contains(@class, "nim-dialog_unread ")]/@data-list-id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question