1

I was trying to some selenium program but now I'm stuck at logging in.

  • Here is code => https://pastebin.com/ykTcd1rb
  • When code execute last line of code (username = driver.find_element(By.ID, 'Login')) I get an error (selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="Login"]"})
  • Here is Element which i trying to get <input aria-invalid="false" type="text" class="form-control" name="Login" id="Login" required="">

Please Help me

1 Answer 1

0

As I see, this command more = driver.find_element(By.ID, "dropdownTopRightMenuButton") can't be executed since that element is not visible.
Also, it's not a good idea to use hardcoded sleeps. WebDriverWait expected_conditions should be used instead.
The following code worked for me:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument("start-maximized")

webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
wait = WebDriverWait(driver, 10)

url = "https://portal.librus.pl/rodzina/synergia/loguj"

driver.get(url)
wait.until(EC.element_to_be_clickable((By.ID, "cookieBoxClose"))).click()
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.login-before-btn"))).click()
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "[name='email']"))).send_keys("my_username")
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "[name='password']"))).send_keys("my_password")
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[type='submit']"))).click()

This, of cause, failed to login because I have no valid credentials, but with correct credentials this should work

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.