Iterate over a list of web elements with selenium python

0

I have problems to access each of the elements of a web listing with selenium ( link ), the code I have allows you to surf the web but unfortunately does not leave the first element, repeats the process over and over again over the first. I would like to access each of the films on the card and perform the steps that I have already achieved. I attach the code thanking you for the help.

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time

URL = 'https://www.cineplanet.cl/peliculas'
PATH = 'C:\Program Files\chrome-driver\chromedriver.exe'
XPATH_COMPRAR = '//div[@class="movie-info-details"]/div[@class="movie-info-details--wrapper"]/div[@class="movie-info-details--first-button-wrapper"]/button'
XPATH_FUNCIONES = '//h3[@class="cinema-showcases--summary-name"]'

driver = webdriver.Chrome(PATH)
driver.get(URL)

time.sleep(5)

listado_peliculas = driver.find_elements_by_class_name('movies-list--large-item')

while len(listado_peliculas):
    for movie in listado_peliculas:
        item = driver.find_element_by_class_name('movies-list--large-movie-description-title').text
        time.sleep(5)
        driver.find_element_by_xpath(XPATH_COMPRAR).click()
        funciones = driver.find_elements_by_xpath(XPATH_FUNCIONES)
        for x in range(0,len(funciones)):
            time.sleep(3)
            ActionChains(driver).click(funciones[x]).perform()
        time.sleep(3)
        driver.back()
    driver.find_element_by_css_selector('.movies-list--view-more-button-wrapper .call-to-action--text')

I am using a virtual environment with Python 3 and the corresponding libraries to use selenium.

It should be noted that it has become complicated since the page in question lacks links, ID, value, etc., in its additional tags it does not change its addresses in the domain.

    
asked by nilsoviani 05.06.2018 в 03:33
source

0 answers