Need Help Locating/clicking A Drop Down Located In Table Using Selenium
Solution 1:
Although I'm not certain I understand the problem you're experience (or trying to solve) well enough to help, I will try.
If I were you, attempting to click specific items from a list, I would just create a list of those items in the first place and then loop through it a single time, clicking as I went. The code might look something like this.
item_list = driver.find_elements_by_xpath('//button[@id="dropdownMenu1"]') #you can add further specifications as necessary
At the very least, you can nix a couple for loops
if you would just first create a list of the items you wanted to check. See docs.
Does that help at all? I see that you're already finding elements (rather than just a single element), so I likely don't understand the problem well enough to advise fully. Consider providing greater clarification about your problem/objective in the comments or editing your questions. Thanks and best of luck!
EDIT: Although it's implied in my answer, I should be clearer. I believe that if you're simply trying to reach elements through loops and checks, it likely makes sense to use XPATH. it is best suited to finding very specific (one-off) elements in an XML document. Just my tuppence.
SECOND EDIT:
Here is a list of the links you need (I think):
list_of_links = driver.find_elements_by_xpath('//li[@role="presentation"]/a') # len(list) == 99
Then, as said above, you can just loop this one list and .click()
each link.
for link in list_of_links:
link.click()
Let me know if it works. Best of luck!!
Post a Comment for "Need Help Locating/clicking A Drop Down Located In Table Using Selenium"