|
| 1 | +# Generated by Selenium IDE |
| 2 | +import pytest |
| 3 | +import time |
| 4 | +import json |
| 5 | +from selenium import webdriver |
| 6 | +from selenium.webdriver.common.by import By |
| 7 | +from selenium.webdriver.support import expected_conditions as EC |
| 8 | +from selenium.webdriver.common.action_chains import ActionChains |
| 9 | +from selenium.webdriver.support import expected_conditions |
| 10 | +from selenium.webdriver.support.wait import WebDriverWait |
| 11 | +from selenium.webdriver.common.keys import Keys |
| 12 | +from selenium.webdriver.common.desired_capabilities import DesiredCapabilities |
| 13 | + |
| 14 | + |
| 15 | +class TestNodeSampleApp(): |
| 16 | + def setup_method(self, method): |
| 17 | + print("Waiting 20 sec. ======================================>>>>>>>>>") |
| 18 | + time.sleep(20) |
| 19 | + print("Waited 20 sec. <<<<<<<<<<<<<<<================================") |
| 20 | + |
| 21 | + opt = webdriver.ChromeOptions() |
| 22 | + opt.add_argument("--disable-dev-shm-usage") |
| 23 | + opt.add_argument("--disable-web-security") |
| 24 | + opt.add_argument("--allow-running-insecure-content") |
| 25 | + opt.add_argument("--no-sandbox") |
| 26 | + opt.add_argument("--disable-setuid-sandbox") |
| 27 | + opt.add_argument("--disable-webgl") |
| 28 | + opt.add_argument("--disable-popup-blocking") |
| 29 | + opt.add_argument("--enable-javascript") |
| 30 | + opt.add_argument('--allow-insecure-localhost') |
| 31 | + opt.add_argument('--window-size=1920,1080') |
| 32 | + opt.add_argument("--whitelisted-ips=''") |
| 33 | + |
| 34 | + # opt.add_argument('--headless') |
| 35 | + # self.driver = webdriver.Chrome(options=opt) |
| 36 | + print("Register remote debug driver. ***************************") |
| 37 | + self.driver = webdriver.Remote( |
| 38 | + command_executor='http://chrome:4444/wd/hub', options=opt) |
| 39 | + |
| 40 | + def teardown_method(self, method): |
| 41 | + self.driver.quit() |
| 42 | + |
| 43 | + def _find_and_click(self, timeout_sec, by, by_expr, **kwargs): |
| 44 | + elem = WebDriverWait(self.driver, timeout_sec).until(EC.visibility_of_element_located((by, by_expr))) |
| 45 | + assert elem is not None |
| 46 | + elem.click() |
| 47 | + return elem |
| 48 | + |
| 49 | + def _find_and_sendkey(self, timeout_sec, by, by_expr, txt, **kwargs): |
| 50 | + elem = WebDriverWait(self.driver, timeout_sec).until(EC.visibility_of_element_located((by, by_expr))) |
| 51 | + assert elem is not None |
| 52 | + elem.send_keys(txt) |
| 53 | + return elem |
| 54 | + |
| 55 | + def test_node_sample_app(self): |
| 56 | + print("In test_node_sample_app(): about to connect to FE at http://client:3000 ...") |
| 57 | + self.driver.get("http://client:3000/") |
| 58 | + print("Connected !") |
| 59 | + print("Set window size to 1500 X 1800 ++++++++++++++") |
| 60 | + self.driver.set_window_size(1500, 1800) |
| 61 | + print("Locate button 'Authorize' and click ===================") |
| 62 | + # 3 | click | id=auth_btn | |
| 63 | + elem = self._find_and_click(30, By.ID, "auth_btn") |
| 64 | + # self._find_and_click(30, By.ID, "auth_btn") |
| 65 | + print("Wait 10 sec for the bene login page to show up ===================") |
| 66 | + time.sleep(10) |
| 67 | + print("Locate user name input and type user name ===================") |
| 68 | + self._find_and_sendkey(30, By.ID, "username-textbox", "BBUser10000") |
| 69 | + print("Locate password input and type password ===================") |
| 70 | + self._find_and_sendkey(30, By.ID, "password-textbox", "PW10000!") |
| 71 | + print("Locate login button and click ===================") |
| 72 | + self._find_and_click(30, By.ID, "login-button") |
| 73 | + print("Wait 10 sec for access grant page to show up ===================") |
| 74 | + time.sleep(10) |
| 75 | + print("Locate Approve button and click ===================") |
| 76 | + self._find_and_click(30, By.ID, "approve") |
| 77 | + print("Now should be able to see the Claims page ===================") |
| 78 | + |
0 commit comments