Issue
I'm trying to click on an "Add" button located in diffents page places, and I need to click on it many times as I have a list containing numbers which is equal to numbers of clicking the "Add" button. I've enumerate a that return index and numbers like:
1: 10
2: 9
3: 9
4: 3
5: 4
The index belongs to the location of the "Add" button and the numbers corresponds to the numbers of time I want to click on the "Add" button foreach button location.
Your help is greatly appreciated.
EDIT
Here's the code sample
for location, add in enumerate(get_click_number_by_location):
set_click_by_location[location] = add
for n_location in set_click_by_location.keys():
add_click = self.driver.find_element(By.XPATH, f"//div[@id='part-{n_location}/accordeon']//div[contains(@class,'btn--children')][normalize-space()='Add']")
add_click_by_location = self.driver.execute_script('arguments[0].click()', add_click)
for add in set_click_by_location.values():
add_click_by_location
Solution
I finnaly managed to get a solution, if it could help someone, here's the code:
for location, add in enumerate(get_click_number_by_location):
n_location = location
add_click = self.driver.find_element(By.XPATH, f"//div[@id='part-{n_location}/accordeon']//div[contains(@class,'btn--children')][normalize-space()='Add']")
for add_item in range(add - 1):
self.driver.execute_script('arguments[0].click()', add_click)
Answered By - Jin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.