0

I'm trying to scroll to the bottom of popup page on Stockx to gather all the recent sale prices for an item. But I can't seem to get to the bottom of the popup to click the load more button. This is what I have so far. Help pls.

import bs4 
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys 

PATH = "C:\Program Files (x86)\chromedriver.exe"

driver = webdriver.Chrome(PATH)
driver.get("https://stockx.com/supreme-patchwork-mohair-cardigan-multicolor")
time.sleep(3)
driver.find_element_by_xpath('//*[@id="root"]/div[1]/div[2]/div[2]/div[9]/div/div/div/div[2]/div/div[2]/div/div/button').click()
driver.find_element_by_xpath('//*[@id="root"]/div[1]/div[2]/div[2]/div[9]/div/div/div/div[2]/div/div[1]/div[2]/a').click()
time.sleep(3)
element_in_popup = driver.find_element_by_xpath('/html/body/div[9]/div/div/div/div[2]/div')
while EC.presence_of_element_located((By.XPATH,'/html/body/div[9]/div/div/div/div[2]/div/button')):
    element_in_popup.send_keys(Keys.END) # Use send_keys(Keys.HOME) to scroll up to the top of page
    driver.find_element_by_xpath('/html/body/div[9]/div/div/div/div[2]/div/button').click()
    
cartier_5
  • 47
  • 5

2 Answers2

0

I was able to interact with the pop up modal with css selctor of the button to load more results.

cartier_5
  • 47
  • 5
0

You can get the button with its xpath and click on it as much as you want. Here's the code I used to do that:

    from selenium import webdriver
    import time

    driver = webdriver.Chrome()
    driver.get("https://stockx.com/supreme-patchwork-mohair-cardigan-multicolor")
    time.sleep(2)

    confirm_location_btn = driver.find_element_by_xpath('//*[@id="root"]/div[1]/div[2]/section/div/div[2]/button')
    confirm_location_btn.click()
    time.sleep(2)

    okay_cookies_btn = driver.find_element_by_xpath('//*[@id="root"]/div[2]/div[2]/button')
    okay_cookies_btn.click()
    time.sleep(2)

    view_all_sales_btn = driver.find_element_by_xpath('//*[@id="Supreme Patchwork Mohair Cardigan Multicolor"]/div[2]/div[3]/a')
    view_all_sales_btn.click()
    time.sleep(2)

    thanks_btn = driver.find_element_by_xpath('/html/body/div[7]/div/div/div/div[2]/div/div[1]/div/button')
    thanks_btn.click()
    time.sleep(2)

    load_more_btn = driver.find_element_by_xpath('/html/body/div[7]/div/div/div/div[2]/div/button')
    load_more_btn.click()
    time.sleep(2)
    load_more_btn.click()
groumache
  • 86
  • 3