0

I want to download the currently day files from a folder in sharepoint.

TL;DR: I've tried two ways (scroll down and apply filters) but none worked.

Since sharepoint loads data in batches of 30 files, first I've tried to scroll down the page in order to load the next batch, but with the firefox bug and me trying to scroll down part of the web, it was impossible.

element = browser.find_element_by_xpath('some_path')
actions = ActionChains(browser)
actions.move_to_element(element).perform()

Even I tried to move it little by little for each file not in the screen, but didn't work.

except MoveTargetOutOfBoundsException:
    y_position += 500
    browser.execute_script('window.scrollTo(0, ' + str(y_position) + ');')

So, my next plan was to apply filters (there are buttons, it seems an ez way to do it, right? No...). There are two ways you can set up a date: slider bar and checkbox.

  1. Slider bar

By default appears full and I want to empty it.

This is the default state.

<div id="Slider654" class="ms-Slider-slideBox ms-Slider-showTransitions slideBox-213" aria-disabled="false" role="slider" tabindex="0" data-is-focusable="true" aria-valuemin="0" aria-valuemax="5" aria-valuenow="0" aria-valuetext="Modificado desde 2023" aria-label="Modificado desde 2023. Use las teclas de flecha para filtrar por fecha, desde 2023 a Hoy">
<div class="ms-Slider-line line-215">
    *<span class="ms-Slider-thumb thumb-214" style="left: 0%;"></span>
    <span class="lineContainer-216 ms-Slider-inactive inactiveSection-218" style="width: 0%;"></span>
    *<span class="lineContainer-216 ms-Slider-active activeSection-217" style="width: 0%;"></span>
    *<span class="lineContainer-216 ms-Slider-inactive inactiveSection-218" style="width: 100%;"></span>
</div></div>

And I want to change to this state.

<div id="Slider654" class="ms-Slider-slideBox ms-Slider-showTransitions slideBox-213" aria-disabled="false" role="slider" tabindex="0" data-is-focusable="true" aria-valuemin="0" aria-valuemax="5" aria-valuenow="5" aria-valuetext="Modificado hoy" aria-label="Modificado hoy. Use las teclas de flecha para filtrar por fecha, desde 2023 a Hoy">
<div class="ms-Slider-line line-215">
    *<span class="ms-Slider-thumb thumb-214" style="left: 100%;"></span>
    <span class="lineContainer-216 ms-Slider-inactive inactiveSection-218" style="width: 0%;"></span>
    *<span class="lineContainer-216 ms-Slider-active activeSection-217" style="width: 100%;"></span>
    *<span class="lineContainer-216 ms-Slider-inactive inactiveSection-218" style="width: 0%;"></span>
</div></div>

The * remarks the lines changed plus the aria-valuenow var in the first div that changes the value from 0 to 5.

I've tried to change these values but even changing them, it doesn't refresh the page.

  1. Checkbox

I have the script to check the correct box.

i = 1
exists = True
while exists:
    try:
        f_date_i = browser.find_element_by_xpath('/html/body/div/div/div[2]/div[2]/div/div[4]/div/div/div[4]/div/div/div/div[1]/div[2]/div/div/div/div[' + str(i) + ']/div/div[1]/label/span').text
        d = datetime.strptime(f_date_i, "%d/%m/%Y")
        if d == datetime_today:
            f_date_i = browser.find_element_by_xpath('/html/body/div[1]/div/div[2]/div[2]/div/div[4]/div/div/div[4]/div/div/div/div[1]/div[2]/div/div/div/div[' + str(i) + ']')
            browser.execute_script("arguments[0].setAttribute('data-is-checked','true')", f_date_i)
            exists = False
        i += 1
    except NoSuchElementException:
        exists = False

But when I press 'Apply' button, page doesn't change.

I think I'm missing something with the filters and I have to change something else...

Gaia
  • 31
  • 5

0 Answers0