I'm currently trying to iterate through a feed of clickable items and click them one by one and also scroll down to get new items in view range. The problem is, that I'm clicking the items, based on the length of presence_of_all_elements_located(which I assign to a variable called elem) . When recalling that function, the size of elem keeps increasing till a specific point (about 60 most of the time) and then starts to decrease a little and then it keeps resizing in a range between 40 and 60 even when loading new content. The problem is that I can't click every single element, because at the point of resizing the counter variable I got is not pointing to the next element anymore, but some element at the end of the newly loaded elements. This way I skip many elements. I tried to explain it as best as I can, if you got any questions, just ask. Thanks in advance.
I've tried adjusting my counter variable to the new resizing, but since the resizing keeps to vary I can't fix it this way
Here's the code I'm using:
# iterate through displayed feed
#load all so far reachable elements once
self.elem = WebDriverWait(self.driver, 10).until(
EC.presence_of_all_elements_located((By.CSS_SELECTOR, "classnamehere")))
print("elem1 length: " + str(len(self.elem)))
if self.scroll_position < len(self.elem) - 1:
self.scroll_position += 1
else:
pass
#scroll to picture we want to click on
actions = ActionChains(self.driver)
if self.scroll_position < len(self.elem):
actions.move_to_element(self.elem[self.scroll_position]).perform()
self.elem[self.scroll_position].click()
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)