I am working on a Django project that uses Clusterize.js to dynamically load a list of "datapoints" into a div. On the Javascript / HTML side, the first 200 black box databases are loaded first. If there are more, then the worker is loaded into 1000 data points at a time until all the data is selected and displayed in the scroll list. When a user clicks on a data point, the details of this data set rise.
Initially, an error occurred that would lead to incorrect data for any datatown in the past 199. As soon as any new data outside 199 for any black box is loaded, the wrong datapoint identifier will be passed to the showDatapointDetail Javascript function and the datapoint 200 will receive the part for datapoint 0, datapoint 201 will get details for datapoint 1 etc. until datapoint 1199 gets the details for datapoint 999. Then datapoint 1200 gets 0 and the pattern repeats. Since then, I fixed this error in Javascript code, but now I'm working on writing a good test in tests.py to make sure that clicking on a date-comma for 200 gets the correct data. The project uses Python selenium for numerous browser tests, and now I'm trying to figure out how to use it to scroll the bottom of a dynamically generated div. If I do something like:
dp_detail_199 = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "datapoint199")))
then I can get this data detail correctly, since only 200 are initially loaded. However, if, for example, the black box has 787 data points, then the following will not work:
dp_detail_750 = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "datapoint750")))
because you need to scroll down to start loading the following datapoints. So how can I use Selenium to scroll to the bottom of the list generated by Clusterize? The div is called dp_pane , and I can find it with Selenium, but I'm not sure how to scroll down correctly, especially to the bottom. One thing I tried is to scroll down dp_pane first by doing:
driver.execute_script("arguments[0].scrollTop = 12000", dp_pane)
to go to datapoint 200, and then scroll a bit to find datapoint 205:
while True: dp_pane.send_keys(Keys.PAGE_DOWN) try: dp_detail_205 = driver.find_element_by_id("datapoint205") except NoSuchElementException: ######## DEBUG OUTPUT ######### print "Couldn't find dp_detail_205" continue else: ######## DEBUG OUTPUT ######### print "Found it!" break
but it seems to get stuck and never find datapoint 205; instead, I just get the debug output "Couldn't find dp_detail_205" . What should I do so that I can get Selenium to scroll to the bottom of dp_pane to find, for example, datapoint750 , and check that it has the correct data? Ultimately, I need Selenium to get Clusterize to load more rows, because this is the only thing I need for this test to work, which didn't work at all. Even Clusterize's own method for scrolling programs does not work; the line I would use would be something like this:
document.getElementById('dp_pane').scrollTop = 12000;
but unfortunately, no matter how large the scrollTop value is, it only ever reaches a datapoint value of 199 and will not automatically load more rows.
EDIT:
I recently upgraded the project to Django 1.9, which includes integration with QUnit. At first glance, I suggested that it would be the perfect replacement for selenium for this test. However, now I'm not sure after reading some documents; firstly, the test involves loading the .dat file, which I'm not sure that QUnit can be used. Also, is it easy to automate in Travis CI? Trying to do a working test for this turned out to be difficult, and I'm not sure what else I can try at this point.