Open jgosmann opened 8 years ago
at least on my Macbook
============================= test session starts ============================== platform darwin -- Python 2.7.12, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 rootdir: /Volumes/Home/blubb/Documents/projects/uni/nengo_gui, inifile: collected 1 items nengo_gui/tests/test_spa.py F =================================== FAILURES =================================== ___________________________________ test_spa ___________________________________ driver = <selenium.webdriver.firefox.webdriver.WebDriver (session="b48982de-580f-f944-b196-f82a3d880bdc")> def test_spa(driver): # Tests the functionality of SPA simulations try: #Test page response by clicking the reset button and applying new code to ace-editor test_file = """ import nengo import nengo.spa as spa D = 2 # the dimensionality of the vectors model = spa.SPA() with model: model.color = spa.State(D) model.shape = spa.State(D) model.memory = spa.State(D, feedback=1) model.query = spa.State(D) model.answer = spa.State(D) actions = spa.Actions( "memory = color * shape", "answer = memory * ~query", ) model.cortical = spa.Cortical(actions) """ tt.reset_page(driver) tt.update_editor(driver, test_file) tt.mouse_scroll(driver,200) # Generates semantic pointer clouds for each network driver.execute_script(""" var a = Nengo.netgraph.svg_objects; for(model in a){ if(a[model].sp_targets.length > 0){ a[model].create_graph('Pointer',a[model].sp_targets[0]); a[model].create_graph('SpaSimilarity',a[model].sp_targets[0]); } }; """) time.sleep(1) # Ensures the simulation has started hang_time = 100 # alloted time until test fails compiled = False tt.start_stop_sim(driver) time_start = time.time() while(time.time() - time_start < hang_time): time_script = 'var time = $("#ticks_tr"); \ return time.find("td").text()' sim_time = driver.execute_script(time_script) if(float(sim_time) > 0): compiled = True break time.sleep(1) assert(compiled) # Sets the semantic pointers appropriately spa_values = {"shape":"CIRCLE", "color":"BLUE", "query":"CIRCLE"} set_cloud_value(driver,spa_values) time.sleep(10) result = driver.execute_script(""" var objects = Nengo.Component.components; var answer = objects.filter(function(item){ return item.label.innerHTML == "answer";} )[0]; var answer_data = answer.data_store.data[0]; var result = answer_data.pop(); return result """) data_script = """ shape_data = Nengo.Component.components.filter(function(item){ return (item.constructor === Nengo.SpaSimilarity); })[0].data_store.data; return shape_data; """ plot_data = driver.execute_script(data_script) # Checks that the 'answer' is BLUE assert any("BLUE" in x for x in result) # Checks the dimensionality of the spa similarity plot assert(len(plot_data) == 2 and len(plot_data[0]) > 1) set_cloud_value(driver,{"color":"ORANGE"}) time.sleep(10) plot_data = driver.execute_script(data_script) # Checks that the data store grows when input changes assert(len(plot_data) == 3 and len(plot_data[0]) > 1) except Exception as e: #Travis Only: On fail takes screenshot and uploads it to imgur if('TRAVIS' in os.environ): tt.imgur_screenshot(driver) _, _, tb = sys.exc_info() traceback.print_tb(tb) # Fixed format tb_info = traceback.extract_tb(tb) filename, line, func, text = tb_info[-1] print('An error occurred on line {} in statement {}'.format(line, text)) print(str(e)) > exit(1) nengo_gui/tests/test_spa.py:137: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = Use exit() or Ctrl-D (i.e. EOF) to exit, code = 1 def __call__(self, code=None): # Shells like IDLE catch the SystemExit, but listen when their # stdin wrapper is closed. try: sys.stdin.close() except: pass > raise SystemExit(code) E SystemExit: 1 ../../../../.virtualenvs/nengogui/lib/python2.7/site.py:403: SystemExit ----------------------------- Captured stdout call ----------------------------- An error occurred on line 192 in statement raise exception_class(message, screen, stacktrace) Message: Unable to locate element: {"method":"xpath","selector":"//*[@id='singleInput']"} Stacktrace: at FirefoxDriver.prototype.findElementInternal_ (file:///var/folders/t7/99gtw6151wz7r76dzhxl08vr0000gn/T/tmp1DK3RX/extensions/fxdriver@googlecode.com/components/driver-component.js:10770) at FirefoxDriver.prototype.findElement (file:///var/folders/t7/99gtw6151wz7r76dzhxl08vr0000gn/T/tmp1DK3RX/extensions/fxdriver@googlecode.com/components/driver-component.js:10779) at DelayedCommand.prototype.executeInternal_/h (file:///var/folders/t7/99gtw6151wz7r76dzhxl08vr0000gn/T/tmp1DK3RX/extensions/fxdriver@googlecode.com/components/command-processor.js:12661) at DelayedCommand.prototype.executeInternal_ (file:///var/folders/t7/99gtw6151wz7r76dzhxl08vr0000gn/T/tmp1DK3RX/extensions/fxdriver@googlecode.com/components/command-processor.js:12666) at DelayedCommand.prototype.execute/< (file:///var/folders/t7/99gtw6151wz7r76dzhxl08vr0000gn/T/tmp1DK3RX/extensions/fxdriver@googlecode.com/components/command-processor.js:12608) ----------------------------- Captured stderr call ----------------------------- File "/Volumes/Home/blubb/Documents/projects/uni/nengo_gui/nengo_gui/tests/test_spa.py", line 88, in test_spa set_cloud_value(driver,spa_values) File "/Volumes/Home/blubb/Documents/projects/uni/nengo_gui/nengo_gui/tests/test_spa.py", line 22, in set_cloud_value field = driver.find_element_by_xpath("//*[@id='singleInput']") File "/Volumes/Home/blubb/.virtualenvs/nengogui/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 293, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/Volumes/Home/blubb/.virtualenvs/nengogui/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 752, in find_element 'value': value})['value'] File "/Volumes/Home/blubb/.virtualenvs/nengogui/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute self.error_handler.check_response(response) File "/Volumes/Home/blubb/.virtualenvs/nengogui/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response raise exception_class(message, screen, stacktrace) ========================== 1 failed in 12.30 seconds ===========================
I've also had this fail sporadically for me. My guess is that the time.sleep calls need to be tweaked, but I wouldn't worry about this for the time being as I plan to improve the testing infrastructure in #806.
time.sleep
at least on my Macbook