i try to click the "Expand All" Button
using the following code:
import timeimport os, sysfrom bs4 import BeautifulSoupfrom selenium import webdriverfrom selenium.webdriver.chrome.options import Optionsfrom selenium.webdriver.chrome.service import Servicefrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.common.by import ByWAIT = 1path = os.path.abspath(os.path.dirname(sys.argv[0])) print(f"Checking Browser driver...")options = Options()# options.add_argument('--headless=new') options.add_argument("start-maximized")options.add_argument('--log-level=3') options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1}) options.add_experimental_option("excludeSwitches", ["enable-automation"])options.add_experimental_option('excludeSwitches', ['enable-logging'])options.add_experimental_option('useAutomationExtension', False)options.add_argument('--disable-blink-features=AutomationControlled') srv=Service()driver = webdriver.Chrome (service=srv, options=options) # driver.minimize_window()waitWD = WebDriverWait (driver, 10) baseLink = "https://tmsearch.uspto.gov/search/search-information"print(f"Working for {baseLink}") driver.get (baseLink) waitWD.until(EC.presence_of_element_located((By.XPATH,'//input[@id="searchbar"]'))).send_keys("SpaceX")waitWD.until(EC.element_to_be_clickable((By.XPATH, '//button[@class="btn btn-primary md-icon ng-star-inserted"]'))).click() waitWD.until(EC.presence_of_element_located((By.XPATH,'//input[@id="goodsAndServices"]'))).send_keys("shirt")waitWD.until(EC.element_to_be_clickable((By.XPATH, '//button[@class="btn btn-primary md-icon ng-star-inserted"]'))).click() time.sleep(WAIT)soup = BeautifulSoup (driver.page_source, 'lxml') driver.execute_script("arguments[0].click();", waitWD.until(EC.element_to_be_clickable((By.XPATH, "(//span[text()=' wordmark '])[1]")))) time.sleep(WAIT) driver.execute_script("arguments[0].click();", waitWD.until(EC.presence_of_element_located((By.XPATH, '//div[@class="expand_all expanded"]'))))
but i only get this error
Working for https://tmsearch.uspto.gov/search/search-informationTraceback (most recent call last): File "F:\DEV\Fiverr2024\TRY\cliff_ckshorts\temp.py", line 41, in <module> driver.execute_script("arguments[0].click();", waitWD.until(EC.presence_of_element_located((By.XPATH, '//div[@class="expand_all expanded"]')))) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\DEV\venv\selenium\Lib\site-packages\selenium\webdriver\support\wait.py", line 105, in until raise TimeoutException(message, screen, stacktrace)selenium.common.exceptions.TimeoutException: Message:
How can i press the button on this website using selenium?