0

How do I get the popup validation message "Please tick this box if you want to continue" using Selenium Python in the photo?

<input oninvalid="this.setCustomValidity('Please tick this box if you want to proceed')" oninput="this.setCustomValidity('')" class="form-check-input checkbox-switch-md" type="checkbox" id="registerTermsCheckboxId" required="">
enter image description here

Screenshot

2
  • Hi, @Rst Ozyrt I have updated your question to be a bit more descriptive. I suggest you also add what have you tried so far and which Selenium web driver are you currently using. Also is it Django you are using? Commented May 23, 2022 at 7:38
  • Can you share the link to the web page? Commented May 23, 2022 at 9:40

2 Answers 2

1

Try the below, I hope this will solve your issue.

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait


toolTip = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'registerTermsCheckboxId')))
hov = ActionChains(driver).move_to_element(toolTip)
txt = hov.perform()
tooltipText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'registerTermsCheckboxId'))).text
print(tooltipText)
Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately, the message (text) is not received with this code.
Try to change the locator, or can you share link of the webpage
1

Found a solution to the problem, where I was able to extract the text in the validation message with the following JavaScriptExecutor code:

message_element = driver.find_element(By.XPATH, Locators.acceptCheckButton_xpath)
accept_button_message = driver.execute_script("return arguments[0].validationMessage", message_element)
print("Message : ", accept_button_message)

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.