This makes me so happy!
I am not entirely sure how or why it works.
But I found a working solution in Javascript to the problem preventing me from automating the opening of the second AccordionItem (banner or tab) in a Dash-Python dbc.Accordion, so I could proceed to submit any edits to the original results.
For some reason, you cannot use the standard Python-Selenium variable.click() method.
Please see code under # Find second header banner by xpath and click.
It works.
Here is the code:
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
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
PATH = "C:\Program Files (x86)\chromedriver.exe"
service = Service(PATH)
driver = webdriver.Chrome(service=service)
driver.maximize_window()
driver.get("http://localhost:8050/")
action = ActionChains(driver)
# Confirm connected to web page:
page_title = driver.title
print("Connected to Web Page: ", page_title)
time.sleep(5)
# Find recipe text area.
recipe_textarea = driver.find_element(by=By.ID, value='recipe-textarea')
# Load test data into recipe text area.
recipe_textarea.send_keys("2 cups lentils")
# Find submit button
submit_recipe = driver.find_element(
by=By.ID, value='recipe-textarea-submit-button')
# Click submit button.
submit_recipe.click()
# Scroll down to element
driver.execute_script("window.scrollBy(0,500)", "")
# Find second header banner by xpath and click
tab_two = driver.find_element_by_xpath(
"//button[normalize-space()='Step 2: Edit Initial Results']")
driver.execute_script("arguments[0].click();", tab_two)
# Find submit edits button.
submit_edits = driver.find_element_by_id(
"nutrients-review-datatable-submit-button")
# Click submit edits button
submit_edits.click()