0

I am trying to automate login to this website. While Python adds username and password, it couldn't click on login button "Inloggen". I do not get any error but it does not click on login button.

here is my code:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC


driver = webdriver.Chrome(ChromeDriverManager().install())

url = "https://portal.spryngsms.com/login?redirect=%2F"
username = "cosmos"
password = "12345"

driver.get(url)

driver.get('https://portal.spryngsms.com/login?redirect=%2F')

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, 
"//span[text()='Gebruikersnaam']//following::div[1]//input"))).send_keys("cosmos")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, 
"//span[text()='Wachtwoord']//following::div[1]//input"))).send_keys("12345")

driver.find_element_by_xpath("//span[text()='Wachtwoord']//following::div[1]//input").click()

4 Answers 4

1

Use css selector instead of xpath. It's work for me

driver.find_element_by_css_selector("#app > div.application--wrap > div.tw-flex.tw-w-full.tw-pr-8 > div > div > div > div > div > section > form > footer > div.form__footer-bottom.form__footer-bottom--login > div > button").click()
Sign up to request clarification or add additional context in comments.

Comments

0

I recommend you to check the selector for button first, seems like you are trying to click onto password input instead of button.

As @Sumsul Islam said, there is no need to use xpath in this case, each element is accessible by css selectors just fine.

But also it's quite enough to use this selectors instead of full css path:

//login
input[type="text"]

//password
input[type="password"]

//button
.form__footer button

Comments

0

Here's an answer that works pretty good with xpath:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC


driver = webdriver.Chrome(ChromeDriverManager().install())

url = "https://portal.spryngsms.com/login?redirect=%2F"
username = "cosmos"
password = "12345"

driver.get(url)

driver.get('https://portal.spryngsms.com/login?redirect=%2F')

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, 
"//span[text()='Gebruikersnaam']//following::div[1]//input"))).send_keys("cosmos")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, 
"//span[text()='Wachtwoord']//following::div[1]//input"))).send_keys("12345")

driver.find_element_by_xpath("/html/body/div[1]/div[3]/div[1]/div/div/div/div/div/section/form/footer/div[2]/div/button").click()

Whether you're using Firefox or chrome, You can use inspect the element and right-click on your desired element and select copy > copy xpath

You can use copy CSS selectors as well:

driver.find_element_by_css_selector(".form__footer-bottom > div:nth-child(1) > button:nth-child(1)").click()

Comments

0

Use WebDriverWait() and wait for element_to_be_clickable() and following locator.

Xpath:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,"//button[contains(.,'Inloggen')]"))).click()

Css Selector:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"div[class='mi-button__Container']> .button--normal.icon.button--normal-secondary.button--mi"))).click()

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.