1

Taking this instagram link for eg. https://www.instagram.com/janelaverdegarden/, I want to load all the images by scrolling to the bottom of the page. To do that, I have to click LOAD MORE button, scroll down to bottom page, wait for page to load, scroll up abit, and scroll down to bottom page and wait for page to load again till no more images are left (manually).

However, I want to load the page automatically using Selenium. Thus, initially, I thought that once the page is fully loaded to the end of the page with all the images, the web element rbSensor will disappear, allowing me to mark that the page has reached the bottom with no more images to be loaded. However, it still remains there. So is there any other way to check if the page is fully loaded with all the images?

<div data-reactid=".0.1.0.1:$mostRecentSection/=10">
     <div class="_nljxa" data-reactid=".0.1.0.1:$mostRecentSection/=10.0">
     <div class="ResponsiveBlock" data-reactid=".0.1.0.1:$mostRecentSection/=10.1">
             <div class="rbSensor" data-reactid=".0.1.0.1:$mostRecentSection/=10.1.$sensor">
                    <iframe class="rbSensorFrame" data-reactid=".0.1.0.1:$mostRecentSection/=10.1.$sensor.0"/>
                    </div>
      </div>
</div>

Code. As I used rbSensor to load the page, even if the page is fully loaded with all the images, the element will still be clicked continuously as the element is still in the html.

while (driver.findElements(By.className("rbSensor")).size() > 0) { 
    jse.executeScript("window.scrollTo(0,-300)"); //scroll up abit
    //click on button if found
    driver.findElement(By.className("rbSensor")).click(); 
    Thread.sleep(2000); //pause for 2 seconds
}

Using the answer below in Page scroll up or down in Selenium WebDriver (Selenium 2) using java is not what I want and will not work in this case.

jse.executeScript("window.scrollBy(0,250)", "");
Community
  • 1
  • 1

1 Answers1

1

Try using a different class name

className("_oidfu")

has href attribute

Scrolling answer can be found here: Page scroll up or down in Selenium WebDriver (Selenium 2) using java

Community
  • 1
  • 1
  • `_pupj3` is used only for the LOAD MORE, so even after I clicked it, I still need to scroll the page in order to load the rest of the images – newbie_224466 Jan 20 '16 at 04:23
  • @newbie_224466 What is the purpose for this project? You can get the images after load more is clicked by getting the img src attribute located in
    – ChampTechNET Jan 20 '16 at 04:28
  • I want to load all the images in the instagram page. As after clicking the LOAD MORE, scrolling is required to load the remaining images if there are more to be loaded. I need something to help me identify that the page is fully loaded and there are no more images to be loaded. – newbie_224466 Jan 20 '16 at 04:34
  • @newbie_224466 You may find your answer here then http://stackoverflow.com/questions/12293158/page-scroll-up-or-down-in-selenium-webdriver-selenium-2-using-java – ChampTechNET Jan 20 '16 at 04:36