[Python] Trying to click button in full screen pop up (selenium python)

Discussão em 'Python' iniciado por Stack, Maio 10, 2025.

  1. Stack

    Stack Membro Participativo

    Working on bot that can help me fill out my checkout information. Using Python and Selenium

    window i'm stuck on and can't click on the second prompt. Just popmart checkout options if you'd like to look

    I tried both XPATH and ActionPath, but ActionPath doesn't click on what I need it to, and XPATH says selenium.common.exceptions.NoSuchElementException

    Here is my code so far:

    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver import ActionChains
    import time

    driverpath = Service("/Users/kailaniparadise/Desktop/labubot/chromedriver")
    driver = webdriver.Chrome(service=driverpath)
    # service = Service(executable_path = "chromedriver.exe")
    # driver = webdriver.Chrome(service = service)

    driver.get("https://www.popmart.com/us/products/1809/SKULLPANDA-Winter-Symphony-Series-Plush")

    WebDriverWait(driver, 7).until(
    EC.presence_of_element_located((By.CLASS_NAME, "policy_acceptBtn__ZNU71"))
    )

    #accept terms and conditions
    acceptconditions = driver.find_element(By.CLASS_NAME, "policy_acceptBtn__ZNU71")
    acceptconditions.click()

    time.sleep(3)

    #choose set
    set = driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div[3]/div[1]/div[2]/div[2]/div/div[2]/div[2]/div[2]")
    set.click()
    #time.sleep(1)

    #add to cart
    cart = driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div[3]/div[1]/div[2]/div[2]/div/div[5]/div")
    cart.click()
    #time.sleep(1)

    #go to bag
    bag = driver.find_element(By.CLASS_NAME, "index_cartItem__xumFD")
    bag.click()

    #select an item
    WebDriverWait(driver, 5).until(
    EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/div/div/div[2]/div/div[3]/button"))
    )
    select_all = driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/div/div/div[1]/div/div[1]/div[1]/div[1]")
    select_all.click()

    #confirm checkout
    checkout_button = driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/div/div/div[2]/div/div[3]/button")
    checkout_button.click()

    #checkout as member
    time.sleep(2)

    #XPATH attempt 2
    #driver.find_element(By.XPATH, "//button[text() = 'CHECKOUT AS MEMBER']").click()


    #XPATH attempt 1
    #member = driver.find_element(By.XPATH, "/html/body/div[7]/div/div[2]/div/div[2]/div/button[2]")
    #member.click()


    #ACTION PATH ATTEMPT
    #action = ActionChains(driver)
    #action.move_to_element(driver.find_element(By.XPATH, "//span[text()= 'CHECKOUT AS MEMBER']"))
    #action.click()


    #confirmation
    print("Ready to Checkout!")
    time.sleep(5)

    Continue reading...

Compartilhe esta Página