1- import difflib
21import os
2+ import requests
33from time import sleep
44
55from selenium .common .exceptions import TimeoutException
88from selenium .webdriver .common .by import By
99from selenium .webdriver .support import expected_conditions as EC
1010from selenium .webdriver .support .ui import WebDriverWait
11- from seleniumrequests import Chrome
11+ from selenium . webdriver import Chrome
1212
1313from app .config import Config
1414
@@ -20,16 +20,21 @@ def test_basic_training():
2020 chrome_options .add_argument ('--no-sandbox' )
2121 chrome_options .add_argument ('--headless' )
2222 chrome_options .add_argument ("--disable-user-media-security" )
23- chrome_options .add_argument ("--use-fake-ui-for-media-stream" )
2423 chrome_options .add_argument ("--use-fake-device-for-media-stream" )
2524 chrome_options .add_argument ("--use-fake-ui-for-media-stream" )
2625 chrome_options .add_argument ('--use-file-for-fake-audio-capture={}/simple_phrases_russian.wav' .format (os .getcwd ()))
27- chrome_options .add_experimental_option ('detach' , True )
26+ # chrome_options.add_experimental_option('detach', True)
27+
28+ chrome_options .set_capability ("goog:loggingPrefs" , {"browser" : "ALL" })
29+
2830 driver = Chrome (options = chrome_options )
31+ session = requests .Session ()
2932
3033 sleep (5 )
3134
32- driver .request ('POST' , 'http://127.0.0.1:5000/lti' , data = {
35+ driver .get ('http://web:5000/init/' )
36+
37+ session .request ('POST' ,'http://web:5000/lti' , data = {
3338 'lis_person_name_full' : Config .c .testing .lis_person_name_full ,
3439 'ext_user_username' : Config .c .testing .session_id ,
3540 'custom_task_id' : Config .c .testing .custom_task_id ,
@@ -44,28 +49,37 @@ def test_basic_training():
4449 })
4550
4651 driver .get ('http://web:5000/upload_presentation/' )
47-
52+
4853 file_input = WebDriverWait (driver , 20 ).until (EC .visibility_of_element_located ((By .CSS_SELECTOR , "input[type=file]" )))
4954 file_input .send_keys (f'{ os .getcwd ()} /test_data/test_presentation_file_0.pdf' )
5055
51- cur = driver .page_source
52- print (cur )
5356 WebDriverWait (driver , 5 ).until (EC .element_to_be_clickable ((By .ID , "button-submit" ))).click ()
5457
55- sleep (10 )
56- print (* difflib .unified_diff (cur , driver .page_source )) # <p id="error-text">No task attempt with task_attempt_id = None.</p>
57- print (driver .page_source )
58+ WebDriverWait (driver , 10 ).until (EC .visibility_of_element_located ((By .ID , "next" )))
5859
5960 WebDriverWait (driver , 10 ).until (EC .element_to_be_clickable ((By .ID , "record" ))).click ()
6061
62+ WebDriverWait (driver , 10 ).until (EC .presence_of_element_located ((By .ID , "model-timer" )))
63+
64+ WebDriverWait (driver , 10 ).until (EC .invisibility_of_element ((By .ID , "model-timer" )))
65+
66+ logs = driver .get_log ('browser' )
67+ for entry in logs :
68+ print (f"{ entry ['level' ]} - { entry ['message' ]} " )
69+
70+ # print(driver.find_element(By.ID, "next").is_enabled())
71+ # print(driver.find_element(By.ID, "next").get_attribute('disabled'))
6172
62- # WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "model-timer")))
63- # WebDriverWait(driver, 10).until(EC.invisibility_of_element((By.ID, "model-timer")))
6473 # WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "next")))
6574 # sleep(5)
75+ # print(cur == driver.page_source)
76+ # print(difflib.unified_diff(cur, driver.page_source))
77+ # print(driver.page_source)
78+
6679 # WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "next"))).click()
6780 # sleep(5)
6881 # WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.ID, "done"))).click()
82+
6983 # alert = Alert(driver)
7084 # alert.accept()
7185
0 commit comments