def do_check_device_list(test_user): # Do a fresh login log_in_clean(*test_user.auth) # Navigate to the Devices page splinter_tests.visit("/#/devices") do_sleep(multiplier=0.5) assert_that(browser.title, starts_with("XBee Gateways in your account")) # Make sure we didn't get redirected away or anything assert_that(browser.url, ends_with("#/devices")) # Check the contents of the page assert browser.is_text_present("XBee Gateways in your account") assert not browser.find_link_by_text("Manage Devices").is_empty() # Allow the device list fetch to complete. (Should be wicked fast on # integration test backend.) do_sleep(multiplier=0.5) def check_devices(): for device in test_user.devices['items']: assert browser.is_text_present(device['devConnectwareId']) if device.get('dpDescription'): assert browser.is_text_present(device['dpDescription']) # Check the connection status indicator is correct. conn_status = device.get('dpConnectionStatus', "0") conn_image = "device_disconnected.png" try: if int(conn_status): conn_image = "device_connected.png" except (ValueError, TypeError): pass # Find the image. This XPath ensures that the connection status # image is in the cell immediately before the device ID. xpath = '//td[.="{}"]/preceding-sibling::td[1]/img' xpath = xpath.format(device['devConnectwareId']) img = browser.find_by_xpath(xpath) assert not img.is_empty() assert_that(len(img), is_(1)) assert_that(img.first['src'], ends_with(conn_image)) # Check the device list right now check_devices() # Refresh the list, check it again. ref_button = browser.find_by_xpath('//button[contains(., "Refresh List")]') assert not ref_button.is_empty() ref_button.click() # Wait for list to load do_sleep() # Check the list again check_devices()
def clean_slate(): # Delete all the dashboards delete_all_dashboards("test_user", "e2e_password", "login.etherios.com") # Log back in log_in_clean("test_user", "e2e_password", "login.etherios.com") # With no dashboards, logging in should lead to the dashboard setup page. assert_that(browser.url, ends_with("#/setup"))
def log_in(*auth): delete_all_dashboards(*auth) add_empty_dashboard(*auth) log_in_clean(*auth) splinter_tests.visit("/#/add_widget") # Wait a moment for everything to settle do_sleep() with screenshot_on_exception("log_in_not_add_widget"): assert_that(browser.url, ends_with('/#/add_widget'))