Untitled
plain_text
2 months ago
7.6 kB
2
Indexable
Never
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.keys import Keys import time from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC # Initialize Chrome WebDriver chromedriver_path = "D:\ClearWave\Python\KIOS\chromedriver_win32\chromedriver.exe" chrome_options = webdriver.ChromeOptions() driver = webdriver.Chrome(service=Service(executable_path=chromedriver_path), options=chrome_options) timeout = 15 def click_elements_with_replacement(characters): base_xpath = '//button[@id="btn__digit"]' char_mapping = { '1': 'One', '2': 'Two', '3': 'Three', '4': 'Four', # Add more mappings as needed } try: for char in characters: xpath_with_char = base_xpath.replace("__digit", char_mapping.get(char, char)) element = driver.find_element(By.XPATH, xpath_with_char) element.click() time.sleep(0.2) except Exception as e: print("An error occurred:", e) # Open the page driver.get('https://staging.clearwaveinc.com/KioskMVC/register') driver.maximize_window() ####Page1 - Enter the serialNumber, PIN, click Next : serialNumber_input = driver.find_element(By.XPATH, '//input[@name="value1"]') pin_input = driver.find_element(By.XPATH, '//input[@name="value2"]') next_btn = driver.find_element(By.XPATH, '//button[@id="btnNext"]') # Enter the serialNumber, PIN, click Next time.sleep(3) serialNumber_input.click() click_elements_with_replacement(serialNumber) pin_input.click() click_elements_with_replacement(PIN) next_btn.click() ####Page2: touchHereToBengin_btn = driver.find_element(By.XPATH, '//button[@id="btnStart"]') try: firstName_Input = WebDriverWait(driver, timeout).until( EC.presence_of_element_located(touchHereToBengin_btn) ) except Exception: print("Element not found within the specified timeout.") touchHereToBengin_btn.click() ####Page3: time.sleep(3) try: firstName_Input = WebDriverWait(driver, timeout).until( EC.presence_of_element_located(driver.find_element(By.XPATH, '//input[@id="valueInput"]')) ) except Exception: print("Element not found within the specified timeout.") click_elements_with_replacement(firstName) next_btn = driver.find_element(By.XPATH, '//button[@id="btnNext"]') next_btn.click() ####Page4: time.sleep(3) try: firstName_Input = WebDriverWait(driver, timeout).until( EC.presence_of_element_located(driver.find_element(By.XPATH, '//input[@id="valueInput"]')) ) except Exception: print("Element not found within the specified timeout.") click_elements_with_replacement(lastName) next_btn = driver.find_element(By.XPATH, '//button[@id="btnNext"]') next_btn.click() ####Page5 - Year of Birth: try: firstName_Input = WebDriverWait(driver, timeout).until( EC.presence_of_element_located(driver.find_element(By.XPATH, '//button[@id="btnJanuary"]')) ) except Exception: print("Element not found within the specified timeout.") month_btn = driver.find_element(By.XPATH, '//button[@id="btnJanuary"]') month_btn.click() try: firstName_Input = WebDriverWait(driver, timeout).until( EC.presence_of_element_located(driver.find_element(By.XPATH, '//button[@id="btnDay05"]')) ) except Exception: print("Element not found within the specified timeout.") date_btn = driver.find_element(By.XPATH, '//button[@id="btnDay05"]') date_btn.click() try: firstName_Input = WebDriverWait(driver, timeout).until( EC.presence_of_element_located(driver.find_element(By.XPATH, '//button[@id="btnOne"]')) ) except Exception: print("Element not found within the specified timeout.") one_btn = driver.find_element(By.XPATH, '//button[@id="btnOne"]') nine_btn = driver.find_element(By.XPATH, '//button[@id="btnNine"]') four_btn = driver.find_element(By.XPATH, '//button[@id="btnFour"]') one_btn.click() nine_btn.click() four_btn.click() one_btn.click() next_btn = driver.find_element(By.XPATH, '//button[@id="btnNext"]') next_btn.click() # ####Page6: # male_btn = driver.find_element(By.XPATH, '//button[@data-value-code="male"]') # try: # firstName_Input = WebDriverWait(driver, timeout).until( # EC.presence_of_element_located(male_btn) # ) # except Exception: # print("Element not found within the specified timeout.") # male_btn.click() # ####Page7: # bCBSMap_btn = driver.find_element(By.XPATH, '//button[div[text()="BCBSMap"]]') # try: # firstName_Input = WebDriverWait(driver, timeout).until( # EC.presence_of_element_located(bCBSMap_btn) # ) # except Exception: # print("Element not found within the specified timeout.") # bCBSMap_btn.click() # ####Page8 - Enter patient's primary insurance member ID: # insuranceMemberId_Input = driver.find_element(By.XPATH, '//input[@id="valueInput"]') # try: # firstName_Input = WebDriverWait(driver, timeout).until( # EC.presence_of_element_located(insuranceMemberId_Input) # ) # except Exception: # print("Element not found within the specified timeout.") # insuranceMemberId_Input.send_keys(memberID) # ####Page9- Patient's relationship: # self_btn = driver.find_element(By.XPATH, '//button[div[text()="Self"]]') # try: # firstName_Input = WebDriverWait(driver, timeout).until( # EC.presence_of_element_located(self_btn) # ) # except Exception: # print("Element not found within the specified timeout.") # self_btn.click() ####Page10- Personal Information: next_btn = driver.find_element(By.XPATH, '//button[@id="btnNext"]') next_btn.click() ####Page11- Enter the first and last name of patient's Emergency Contact: try: firstName_Input = WebDriverWait(driver, timeout).until( EC.presence_of_element_located(driver.find_element(By.XPATH, '//button[div[text()="I prefer not to answer"]]')) ) except Exception: print("Element not found within the specified timeout.") iPreferNotToAnswer_btn = driver.find_element(By.XPATH, '//button[div[text()="I prefer not to answer"]]') iPreferNotToAnswer_btn.click() ####Page12- Enter the first and last name of patient's primari care physician: iPreferNotToAnswer_btn = driver.find_element(By.XPATH, '//button[div[text()="I prefer not to answer"]]') iPreferNotToAnswer_btn.click() ####Page13- Select patient's race: iPreferNotToAnswer_btn = driver.find_element(By.XPATH, '//button[div[text()="I prefer not to answer"]]') iPreferNotToAnswer_btn.click() ####Page14- Is the patient Hispanic or Latino: iPreferNotToAnswer_btn = driver.find_element(By.XPATH, '//button[div[text()="I prefer not to answer"]]') iPreferNotToAnswer_btn.click() ####Page15- Select the patient's preferred language: iPreferNotToAnswer_btn = driver.find_element(By.XPATH, '//button[div[text()="I prefer not to answer"]]') iPreferNotToAnswer_btn.click() # ####Page16- Select the patient's current smoking status: # iPreferNotToAnswer_btn.click() ####Page17- Review Personal Information: next_btn = driver.find_element(By.XPATH, '//button[@id="btnNext"]') next_btn.click() # Optional: Add a delay to see the search results time.sleep(10) # Close the browser window # driver.quit()