I have been trying to scroll down an iframe to take screenshots, and thought I found a solution but I am running into a problem where scrolling 500 pixels or 3000 pixels gives me the same results (as well as scrolling by 100, but scrolling by 1 gives me the top of the page so it looked normal for a bit)
The solution was taken from this question, and my current code is as follows:(added the screenshot code just in case, though it doesnt actually reside inside the same def.
def scroll_iframe(self):
iframe = self.driver.find_element_by_id('js-map-iframe')
self.driver.switch_to.frame(iframe)
self.driver.execute_script("window.scrollTo(0,3000);")
time.sleep(5)
self.driver.switch_to.default_content()
time.sleep(3)
print('iframe scroll_1')
self.driver.set_window_size(1920, 4500)
self.driver.save_screenshot("screenshot.png")
print('screenshot taken')
self.driver.quit()
I'm not too sure which part of the source code would be useful to show, but I have used find_element_by_id as the code looked like this:
<div class="pt-map-iframe-parent" style="width: 375px; height: 31804px;">
<iframe src="long-test" frameborder="0" id="js-map-iframe" style="width: 375px; height: 31804px; transform: scale(1);"></iframe>
The iframe itself has a height of 31804 so iframe height shouldn't be a problem.. Any ideas on how to fix this, and why setting window.scrollTo(0,500) and (0,3000) would give the same result?