0

I want to login to https://in1.dashboard.clevertap.com/login.html through selenium using safari. I'm able to enter username and password however since both of them have an ID, however with any of the selenium methods to locate a button I'm not able to do click on the "Log In" button. When I try it either shows an error or open Google Login. I tried to use two classes one is the button class and the second one is span class which defines the text for the button. All of them have failed.

Here is the code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Safari()
driver.get("https://in1.dashboard.clevertap.com/login.html")
time.sleep(5)

driver.find_element_by_id("input-14").send_keys("[email protected]")
driver.find_element_by_id("input-18").send_keys("password")

#Try-1
#driver.find_element_by_xpath("//button[@class = 'ct-button full-width v-btn v-btn--contained theme--light v-size--default primary']").click();

#Try-2
#driver.find_element_by_xpath("//[@id='app'/div/div/div/div[1]/div/div/div/form/div[4]/button.ct-button full-width v-btn v-btn--contained theme--light v-size--default primary").click()

#Try-3
#driver.find_element_by_css_selector("button.ct-button full-width v-btn v-btn--contained theme--light v-size--default primary").click()

#Try-4
#driver.find_element_by_class_name("ct-button full-width v-btn v-btn--contained theme--light v-size--default primary").click()

#Try-5
#driver.find_element_by_xpath("//button[@class = 'v-btn__content']").click();

#Try-6
#driver.find_element_by_xpath("//[@id='app'/div/div/div/div[1]/div/div/div/form/div[4]/button/span.v-btn__content").click()

#Try-7
#driver.find_element_by_css_selector("button.v-btn__content").click()

#Try-8
#driver.find_element_by_class_name("v-btn__content").click()
0

4 Answers 4

1

It is a span, not button which has that class. try

driver.find_element_by_css_selector("span.v-btn__content").click()

alternatively you could use

driver.find_element_by_css_selector('button.ct-button.full-width.v-btn.v-btn--contained.theme--light.v-size--default.primary').click()
Sign up to request clarification or add additional context in comments.

1 Comment

This worked without any errors.However, instead of logging in, Continue with Google button.
0

click on it using Explicit wait :

wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Log In']/..")))
element.click()

Imports :

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

7 Comments

This worked without any errors.However, instead of logging in, Continue with Google button.
It should click on Log In , that's is exactly where you wanna click right ?
Yes. I want it to click on Log In. However idk why it's clicking on Continue with Google. Continue with Google has separate class and it's own id.
You can try with xpath //span[text()='Log In'] also. However the above code should click on Login button.
I retried, but same result. Can we presume that it might be a Safari issue? Should I try with another browser?
|
0

See if this works:-

driver.find_element_by_xpath(".//span[text()='Log In']/..").click()

1 Comment

This worked without any errors.However, instead of logging in, Continue with Google button.
0

try this

driver.find_element_by_xpath("/html/body/div[1]/div[1]/div/div/div[1]/div[1]/div/div/div/form/div[4]/button")

PS: would be nice to have the error for better understanding

2 Comments

Do not use absolute xpath, always use relative xpath
Agreed. Absolute xpath will be problematic if the structure is changed. However, I tried the above and it ran and opened the Continue with Google button.

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.