22
33from selenium import webdriver
44from selenium .webdriver .chrome .service import Service
5+ from selenium .webdriver .chrome .options import Options
6+ from selenium .webdriver .support import expected_conditions
7+ from selenium .webdriver .common .by import By
8+ from selenium .webdriver .support .ui import WebDriverWait
9+ from bs4 import BeautifulSoup
510
6- #driver = webdriver.Chrome(service = service) # Optional argument, if not specified will search path.
11+ DEFAULT_TEXT = " Schritt 3 von 5 : Terminvorschläge - Keine Zeiten verfügbar "
12+ URL1 = "https://termine.staedteregion-aachen.de/auslaenderamt/"
13+ URL2 = "https://termine.staedteregion-aachen.de/auslaenderamt/select2?md=1"
14+ URL3 = "https://termine.staedteregion-aachen.de/auslaenderamt/suggest?mdt=75&select_cnc=1&cnc-204=0&cnc-205=0&cnc-198=0&cnc-201=0&cnc-202=0&cnc-227=0&cnc-189=0&cnc-203=0&cnc-196=0&cnc-190=0&cnc-185=0&cnc-187=0&cnc-188=0&cnc-186=0&cnc-192=0&cnc-191=1&cnc-194=0&cnc-197=0&cnc-193=0&cnc-183=0&cnc-184=0&cnc-195=0&cnc-200=0&cnc-225=0"
715
16+ print ("Starting Selenium Test" )
17+
18+ options = Options ()
19+ options .add_argument ("--headless=new" )
820service = Service (executable_path = "/usr/bin/chromedriver" )
9- driver = webdriver .Chrome (service = service )
21+ driver = webdriver .Chrome (service = service , options = options )
22+ driver .get (URL1 )
23+ time .sleep (3 ) # Let the user actually see something!
24+ cookie = driver .find_element (by = "id" , value = "cookie_msg_btn_yes" )
25+ cookie .click ()
26+ time .sleep (2 )
27+ driver .get (URL2 )
28+ time .sleep (2 )
29+ driver .get (URL3 )
30+ WebDriverWait (driver , 20 ).until (expected_conditions .visibility_of_element_located ((By .NAME , "select_location" )))
31+ element = driver .find_element (by = By .NAME , value = "select_location" )
1032
11- driver .get ("https://www.selenium.dev/selenium/web/web-form.html" )
12- time .sleep (5 ) # Let the user actually see something!
33+ element .click ()
1334
35+ time .sleep (2 )
1436driver .save_screenshot ('screen.png' )
15- time .sleep (5 ) # Let the user actually see something!
1637
17- driver .quit ()
38+ soup = BeautifulSoup (driver .page_source , "html.parser" )
39+ inhalt = soup .find (id = "inhalt" )
40+ title_element = inhalt .find ("h1" )
41+ driver .quit ()
42+
43+ print (title_element .text )
44+ print (title_element .text == DEFAULT_TEXT )
0 commit comments