J.Doe J.Doe - 1 month ago 21
Python Question

(Python, Selenium WD) Нow to receive and transfer the list to a cycle?

I have this code

lst = ["Appearence","Logotype", "Catalog", "Product Groups", "Option Groups","Manufacturers","Suppliers",
"Delivery Statuses","Sold Out Statuses", "Quantity Units", "CSV Import/Export", "Countries","Currencies","Customers"]

for item in lst:
assert wd.title != None

I not want to write list by hand.
I want to receive the list - lst directly from the browser.
I use

m = wd.find_elements_by_css_selector('li[id=app-]')


I don't know how to transfer the list to a cycle

look this picture screen browser

Please help me to understand how to use the list and to transfer it to a cycle


In your example variable m will be a list of WebElements you can directly click, to iterate over them just use a for loop:

m = wd.get_elements_by_css_selector('li#app-')

for elem in range(1, len(m)+1):
    assert wd.title is not None