Aktywne Wpisy

Graner +23

Wazzzup 0
Trafił mi się do przejęcia leasing BMW serii 4 z końca 2022 roku, niski przebieg, salon PL. Auto wyglada bardzo fajnie, obecny (drugi od nowości) użytkownik ma podobno problemy finansowe i chce szybko odstąpić bez odstępnego, bo rata wynosi prawie 5 tyś zł netto. Umowa na jakieś 160 tys zł, a wartość auta ok 180-190. Jednak po sprawdzeniu historii okazało się, że auto miało od nowości już 4 szkody:
1) Przód o
1) Przód o





Mireczki, próbuję się pobawić Pythonem trochę; przy pomocy GPT, nie jestem programistą. Chcę stworzyć skrypt, używając Selenium, który automatycznie loguje się do Librusa i natknąłem się na problem. Chat kręci się w kółko i nie jest chyba w stanie dojść do sedna problemu.
Ale do rzeczy. Skrypt wyszukuje poprawnie przycisk LIBRUS SYNEGRIA, klika go, potem poprawnie lokalizuje przycisk ZALOGUJ i go klika. Ale po przejściu do formularza logowania, nie wpisuje nazwy użytkownika i hasła. Jakby nie widział w ogóle formularza? Nie wiem. Może jest ktoś na tagu, kto mógłby rzucić na to okiem i pokierować w odpowiedniem kierunku?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expectedconditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import time
driverpath = '/usr/local/bin/chromedriver'
chromeoptions = Options()
chromeoptions.binarylocation = '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser'
chromeoptions.addargument("--no-sandbox")
chromeoptions.addargument("--disable-dev-shm-usage")
service = Service(driverpath)
driver = webdriver.Chrome(service=service, options=chromeoptions)
try:
print("Navigating to the main page")
driver.get('https://portal.librus.pl/rodzina')
print("Waiting for the cookie consent button to be visible")
consentbutton = WebDriverWait(driver, 20).until(
EC.visibilityofelement_located((By.XPATH, '//*[@id="consent-categories-description"]/div[2]/div/div/button[2]'))
)
print("Cookie consent button found, clicking it.")
consentbutton.click()
time.sleep(3)
print("Waiting for the LIBRUS SYNERGIA button")
librusbutton = WebDriverWait(driver, 20).until(
EC.elementtobeclickable((By.XPATH, '/html/body/nav/div/div[1]/div/div[2]/a[3]'))
)
librusbutton.click()
time.sleep(3)
print("Waiting for the ZALOGUJ button")
zalogujbutton = WebDriverWait(driver, 20).until(
EC.elementtobeclickable((By.XPATH, '/html/body/nav/div/div[1]/div/div[2]/div/a[2]'))
)
zalogujbutton.click()
time.sleep(3)
print("Waiting for the login form to load")
usernamefield = WebDriverWait(driver, 20).until(
EC.visibilityofelementlocated((By.ID, 'Login'))
)
print("Username field found.")
usernamefield.sendkeys('username')
passwordfield = WebDriverWait(driver, 20).until(
EC.visibilityofelementlocated((By.ID, 'Pass'))
)
print("Password field found.")
passwordfield.sendkeys("password")
print("Clicking the submit button")
submitbutton = driver.findelement(By.ID, 'LoginBtn')
submitbutton.click()
print("Waiting for the next page to load...")
time.sleep(10)
except Exception as e:
print(f"An error occurred: {e}")
input("Press Enter to close the browser...")
driver.quit()
@venomik: