|
1 | 1 | from time import sleep |
2 | 2 |
|
3 | | -from selenium_session import SeleniumSession, HOST |
| 3 | +from selenium_session import SeleniumSession |
4 | 4 |
|
5 | 5 | from selenium.webdriver.common.by import By |
6 | 6 | from selenium.webdriver.support import expected_conditions as EC |
7 | 7 | from selenium.webdriver.support.ui import WebDriverWait |
8 | 8 |
|
9 | 9 |
|
10 | | -class Training(SeleniumSession): |
11 | | - def __init__(self, config, chrome_options, requires_init=True): |
12 | | - super().__init__(config, chrome_options, requires_init) |
| 10 | +class Training: |
| 11 | + def __init__(self, selenium: SeleniumSession): |
| 12 | + self.selenium = selenium |
13 | 13 |
|
14 | 14 | def upload_presentation(self, presentation_path): |
15 | | - self.driver.get(f'{self.host}/upload_presentation/') |
| 15 | + self.selenium.driver.get(f'{self.selenium.host}/upload_presentation/') |
16 | 16 |
|
17 | | - file_input = WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input[type=file]"))) |
| 17 | + file_input = WebDriverWait(self.selenium.driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input[type=file]"))) |
18 | 18 | file_input.send_keys(presentation_path) |
19 | 19 |
|
20 | | - WebDriverWait(self.driver, 5).until(EC.element_to_be_clickable((By.ID, "button-submit"))).click() |
| 20 | + WebDriverWait(self.selenium.driver, 5).until(EC.element_to_be_clickable((By.ID, "button-submit"))).click() |
21 | 21 |
|
22 | 22 | def prepare_record(self): |
23 | | - WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.ID, "record"))).click() |
| 23 | + WebDriverWait(self.selenium.driver, 10).until(EC.element_to_be_clickable((By.ID, "record"))).click() |
24 | 24 |
|
25 | | - WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "model-timer"))) |
| 25 | + WebDriverWait(self.selenium.driver, 10).until(EC.presence_of_element_located((By.ID, "model-timer"))) |
26 | 26 |
|
27 | | - WebDriverWait(self.driver, 10).until(EC.invisibility_of_element((By.ID, "model-timer"))) |
| 27 | + WebDriverWait(self.selenium.driver, 10).until(EC.invisibility_of_element((By.ID, "model-timer"))) |
28 | 28 |
|
29 | 29 | def next_slide(self): |
30 | | - WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.ID, "next"))).click() |
| 30 | + WebDriverWait(self.selenium.driver, 10).until(EC.element_to_be_clickable((By.ID, "next"))).click() |
31 | 31 |
|
32 | 32 | def end_training(self): |
33 | | - WebDriverWait(self.driver, 5).until(EC.element_to_be_clickable((By.ID, "done"))).click() |
| 33 | + WebDriverWait(self.selenium.driver, 5).until(EC.element_to_be_clickable((By.ID, "done"))).click() |
34 | 34 |
|
35 | | - WebDriverWait(self.driver, 5).until(lambda d : d.switch_to.alert).accept() |
| 35 | + WebDriverWait(self.selenium.driver, 5).until(lambda d : d.switch_to.alert).accept() |
36 | 36 |
|
37 | 37 | def wait_for_feedback(self, seconds): |
38 | 38 | feedback_flag = False |
39 | 39 | step_count = 10 |
40 | 40 | step = seconds / step_count |
41 | 41 |
|
42 | 42 | for _ in range(step_count): |
43 | | - self.driver.refresh() |
| 43 | + self.selenium.driver.refresh() |
44 | 44 |
|
45 | | - feedback_elements = self.driver.find_elements(By.ID, 'feedback') |
| 45 | + feedback_elements = self.selenium.driver.find_elements(By.ID, 'feedback') |
46 | 46 |
|
47 | 47 | if feedback_elements and feedback_elements[0].text.startswith('Оценка за тренировку'): |
48 | 48 | feedback_flag = True |
|
0 commit comments