in Education by
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)

1 Answer

0 votes
by
Here is the simple solution. elems = WebDriverWait(self.driver, 10).until( EC.presence_of_all_elements_located((By.CSS_SELECTOR, "classnamehere"))) for ele in elems: # this will scroll the element into view ele.location_once_scrolled_into_view # click on the element ele.click() # if .click() not worked then comment that above line and use below line #driver.execute_script("arguments[0].click();",ele)

Related questions

0 votes
    I have the list of sets like so. I basically want to convert this to the dictionary and to address duplicate keys, ... ] = val return d Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    I have some data either in a list of lists or a list of tuples, like this: data = [[1,2,3], [4,5, ... store tuples or lists in my list? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    How to remove an element from a list by index in Python, I tried list.remove method but it search the list and ... How can I do this? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    How can I delete an element from a dictionary? In order to return a copy, how can I delete an element/ ... modifying the original)? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I have a certain element that I can select with Selenium 1. Unfortunately, I need to click the parent element ... upwards with XPath? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    What will be the output of the following Python function? min(max(False,-3,-4), 2,7) a) -4 b) -3 c) 2 d) False...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    I can use vi{ and va{ to select C++ code blocks. It helps me a lot when I need to yank ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I have two list that I combine into a single list. Later I want to make a copy of this list so ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 27, 2022 in Education by JackTerrance
0 votes
    I have an object with an attribute that is a list. For example: obj.a = [3, 4, 5] I ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I'm curious about manipulating time in Python. I can get the (last modified) age of a file using ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I have an object with an attribute that is a list. For example: obj.a = [3, 4, 5] I ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    I want to run a python script from a shell script. I have been able to run it from the "command ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
0 votes
    I want to run a python script from a shell script. I have been able to run it from the "command ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: asynchronous python itertools chain multiple generators (2 answers) Closed 2 ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I have a variable of z storing features of length and height of image files where z is z = [ ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
...