Reputation: 21
https://agent.loadbook.in/#/login When I go to the signup form, the form has a checkbox as I agree with the condition. It's an Input tag checkbox. when I select the tag by id and when I perform click or send_key of submitting its showing checkbox not clickable.
below all Method are not work
driver.find_element_by_xpath('//div[@class="switch__container"]//input').click()
driver.find_element_by_xpath('//div[@class="switch__container"]//input').send_keys(Keys.ENTER)
driver.find_element_by_xpath('//div[@class="switch__container"]//input').submit()
driver.find_element_by_xpath('//div[@class="switch__container"]//input').send_keys("after")
driver.find_element_by_xpath('//div[@class="switch__container"]//label').click()
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://agent.loadbook.in/#/login")
driver.find_element_by_partial_link_text("Create an account").click()
try:
driver.find_element_by_xpath('//div[@class="switch__container"]//input').click()
# driver.find_element("name","username").send_keys("test")
# driver.find_element("name","email").send_keys("[email protected]")
# driver.find_element("name","phone").send_keys("99999999")
# driver.find_element("name","password").send_keys("12345")
except NoSuchElementException as exception: print("not found")
selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable
Upvotes: 1
Views: 2444
Reputation: 193108
To click()
on the checkbox asociated with text as I agree to the Terms and Conditions and Privacy Policy you have to induce WebDriverWait for the element to be clickable and you can use the following solution:
Code Block:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
# options.add_argument('disable-infobars')
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
driver.get("https://agent.loadbook.in/#/login")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Create an account"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "label[for='switch-shadow']"))).click()
Browser Snapshot:
Upvotes: 0
Reputation: 168082
You need to wait for the element to appear in DOM using Selenium's Explicit Wait feature.
Open the page using WebDriver.get() function
driver.get("https://agent.loadbook.in/#/login")
Click "Create an account" link:
driver.find_element_by_link_text("Create an account").click()
Wait until the checkbox loads and becomes clickable:
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "switch_div")))
Click the checkbox:
driver.find_element_by_class_name("switch_div").click()
More information: How to use Selenium to test web applications using AJAX technology
Upvotes: 1