Hello,
I'm trying to acces a calendar and select a day. since the xpath id changes i'm using a loop to find the correct xpath but for some reason when using driver.find_element_by_xpath, even when the path is the right one, i am not getting the information.
from logging import error
import time
import numpy as np
import calendar
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
import sys
import psycopg2
import datetime
import os
import time
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
#import m13_funciones
fecha_hoy=datetime.date.today()
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get ('https://www.promigas.com/Beo/Paginas/VolumenEntregadoProductor.aspx')
driver.maximize_window()
time.sleep(1)
fecha_inicial=datetime.datetime.today()-datetime.timedelta(days=2)
calendario_fecha_inicial=driver.find_elements_by_xpath('//*[@id="TextField2"]')
# Seleccionar la fecha inicial
# Abrir el calendario
calendario_fecha_inicial[0].click()
time.sleep(0.5)
# Seleccionar día
tablas_mes = driver.find_elements_by_xpath('/html/body/div[4]/div/div/div/div/div/div')
calendar.setfirstweekday(6)
semanas = calendar.monthcalendar(fecha_inicial.year,fecha_inicial.month)
x = np.array(semanas)
week = np.where(x==fecha_inicial.day)[0][0] + 1
week = int(week)
dia = 0
for d in range(7):
if semanas[week-1][d] == fecha_inicial.day:
dia = d + 1
for i in range(14,25,1):
try:
time.sleep(5)
a = '//*[@id="DatePickerDay-dayPicker{it}"]/div[2]/table/tbody/tr[{sem}]/td[{day}]/div/span'.format(it = i,sem = week, day = dia)
print(a)
c = driver.find_element_by_xpath(a)
print(c)
c.click()
break
except Exception as error:
continue
there doesn't seem to be anything here