I m using Selenium Webdriver and python to automatically schedule an appointment.
Webdriver options:
options = Options()
options.binary_location = /opt/headless-chromium
options.add_argument( --headless )
options.add_argument( --no-sandbox )
options.add_argument( --single-process )
options.add_argument( --disable-dev-shm-usage )
driver = webdriver.Chrome( /opt/chromedriver ,chrome_options=options)
driver.maximize_window()
I was able to select the date I want for the appointment and to find the submit button.
The html of the submit button (you can see the dialog configured at the data-confirm attribute):
<input type="submit" name="commit" value="Reprogramar" id="appointments_submit" data-confirm="{"title":"¿Desea reprogramar esta cita?","ok":"Confirmar","cancel":"Cancelar"}" data-disable-with="Por favor, espere." class="button primary">
How I m finding it:
appointments_submit = driver.find_element(By.ID, appointments_submit )
appointments_submit.click()
However, when I click the submit button, it creates a confirmation dialog (which doesn t appear in the body of the page until this moment). Not matter how much I try, I cannot made the web driver able to locate this element.
Html of the element:
<div class="reveal-overlay" style="display: block;"><div data-reveal="ib04bi-reveal" class="reveal " role="dialog" aria-hidden="false" tabindex="-1" style="display: block; top: 97px;">
<h2 data-confirm-title="" class="h3 text-center alert-icon">¿Desea reprogramar esta cita?</h2>
<p data-confirm-body="" class=""></p>
<div data-confirm-footer="" class="text-center">
<a data-confirm-cancel="" class="button secondary">Cancelar</a>
<a class="button alert">Confirmar</a></div>
<a aria-label="Close modal" class="close-button" data-close="">
<span aria-hidden="true" class="fas fa-times"></span>
</a>
</div></div>
Picture of it: element webdriver cannot locate
This is where is failing:
confirmation_button = driver.find_element(By.CSS_SELECTOR, body > div.reveal-overlay > div > div > a.button.alert )
confirmation_button .click()
[ERROR] NoSuchElementException: Message: no such element: Unable to locate element:
{
"method": "css selector",
"selector": "body > div.reveal-overlay > div > div > a.button.alert"
}
I also tried WebDriverWait but is not working neither as is throwing a TimeOutException:
This didn t work neither.
confirmation_button = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "body > div.reveal-overlay > div > div > a.button.alert")))
confirmation_button .click()
Please help me troubleshoot this issue. I m feeling really stuck with it.
PD: I m running the code in a python3.7 aws lambda function