I have a website which generates more products when I scroll down. Unlike other websites, there is nothing found in the firebug console. So, I am using selenium to simulate a browser. I have made it working but with firefox driver. But, since I am hosting my web server which runs on command line, I am using HTMLUNIT. Can someone tell me how to scroll pages using HTMLUNIT? Here is the code till now:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Remote("http://127.0.0.1:4444/wd/hub",desired_capabilities=webdriver.DesiredCapabilities.HTMLUNITWITHJS)
browser.get("http://www.somewebsite.com/")
x = browser.find_elements_by_xpath("//div[@id='containeriso3']/div/a[1]")
hrefs = [i.get_attribute('href') for i in x]
print len(hrefs)
time.sleep(2)
browser.execute_script("scroll(0, 2500);")
time.sleep(2)
x = browser.find_elements_by_xpath("//div[@id='containeriso3']/div/a[1]")
hrefs = [i.get_attribute('href') for i in x]
print len(hrefs)
Thank you.