I want to write function which click the button then type account and submit. But the program always stop after clicked at first button, but when I look at the driver, the pop up after click button is already appear. Here is my code:
driver.implicitly_wait(10)
print("click add account")
driver.find_element(by=By.XPATH,
value='//*[contains(text(), "Add Account")]').click()
print("Type account...")
driver.find_element(by=By.ID, value='inp-address').send_keys(i)
time.sleep(1)
driver.execute_script("addAccount()")
This is the HTML of the first Button
<button class="btn btn-sm btn-danger" type="button" data-bs-toggle="modal" data-bs-target="#modal-add-account">Add Account</button>
pop up after click appear:
Still has error:
The Account Name field is within a Modal Dialog Box.
To send the desired text you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following locator strategy:
Code Block:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "inp-address"))).send_keys(i)
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC