Issue
I have a list of web elements like this:
menu = self.driver.find_elements(By.CSS_SELECTOR, '[class="partEl__1o8vO"]')
For all the web elements contained in list menu
I have to perform a click, but with my code below the first element in the list is clicked n times instead of clicking one time on all the elements in the list:
menu = self.driver.find_elements(By.CSS_SELECTOR, '[class="partEl__1o8vO"]')
for index, value in enumerate(menu):
value = self.driver.find_element(By.CSS_SELECTOR, '[class="TableRow_clickableRow__1uMJO"]')
value.click()
I know that I'm not looping correctly, but I don't know what I'm doing wrong. Thanks for help.
Solution
Your question is missing debugging details, but I guess the following should work:
menu = self.driver.find_elements(By.CSS_SELECTOR, '[class="partEl__1o8vO"]')
for value in menu:
value.find_element(By.CSS_SELECTOR, '[class="TableRow_clickableRow__1uMJO"]').click()
In case clicking the menu options performs refreshing the page the following should help:
menu = self.driver.find_elements(By.CSS_SELECTOR, '[class="partEl__1o8vO"]')
for value in menu:
value.find_element(By.CSS_SELECTOR, '[class="TableRow_clickableRow__1uMJO"]').click()
menu = self.driver.find_elements(By.CSS_SELECTOR, '[class="partEl__1o8vO"]')
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.