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('')" type="checkbox" id="registerTermsCheckboxId" required="">
CodePudding user response:
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)
CodePudding user response:
I got the text in the 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("Mesage : ", accept_button_message)