I'm trying to submit a form after entering the necessary fields on this website. So far it works if I don't change the tab to "NTETEXPRESS".
imports
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.chrome.options import Options
from selenium.common import exceptions as sel_excpt
from webdriver_manager.chrome import ChromeDriverManager
options = Options()
options.add_argument("disable-popup-blocking")
options.add_experimental_option("detach",True)
chrome_driver_pth = ChromeDriverManager().install()
service = ChromeService(executable_path=chrome_driver_pth)
driver = webdriver.Chrome(service=service, options=options)
other_tab = False
url = r"https://www.texpresslanes.com/pricing/average-rates/"
segment_css = "#details-1-toll"
day = "#details-1-day"
time = "#details-1-time"
submit = "#wpcf7-f9-p10-o1 > form > div.form-row.last-row.grid-2 > div > div > input.wpcf7-form-control.wpcf7-submit.button-secondary"
if other_tab:
net_tab= "#content > div.page-layout > div > div > article > div > div > div > div > section.module.module-traffic.module-pyt-tabs.full-width.simple-tabs.inserted > div > div > div.module-tabs > button.tab2"
WebDriverWait(driver, 15).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, net_tab))
)
WebDriverWait(driver, 15).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, net_tab))
).click()
WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, segment_css)))
select_seg = Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, segment_css)))
if not other_tab:
select_seg.select_by_value("277")
else:
select_seg.select_by_value("283")
days = driver.find_element(By.CSS_SELECTOR, day_css)
time = driver.find_element(By.CSS_SELECTOR, time_css)
Select(days).select_by_value("monday")
Select(time).select_by_value("00:00:00")
# where it fails if other_tab = True
submit_bttn = driver.find_element(By.CSS_SELECTOR, submit)
submit_bttn.click()
The failure message is either a timeout, or a Element is not interactable error for the form submission button.
Things that I've tried
More expected conditional waits / Waiting for the submit button to be clickable
Executing a script
driver.execute("arguments[0].click();",submit_bttn)
# this works when other_tab = False
So I've actually went to the website, entered in all of the necessary fields, and called using the console (on chrome)
document.querySelector("#wpcf7-f9-p10-o1 > form > div.form-row.last-row.grid-2 > div > div > input.wpcf7-form-control.wpcf7-submit.button-secondary").click()
Again, this works with the first tab for the LBJ express, but not for the NTE35W tab. So I don't really know how to proceed.