def test_links_correct(): # First, make sure we're at the dashboard page. yield check_we_are_at_dashboard_page # There shouldn't be any widgets in the dashboard, since we created a blank # dashboard. yield check_dashboard_is_empty expand_username_menu() # Verify the 'Devices', 'Advanced Options' and 'Manage Account' links yield do_check_link("Devices", splinter_tests.SERVER_URL + "/#/devices") yield do_check_link("Advanced Options", splinter_tests.SERVER_URL + "/#/advanced") yield do_check_link("Manage Account", "https://login.etherios.com/home.do") # Verify all the other links that should be on this page. for linktext, url in get_general_page_links(): yield do_check_link(linktext, url)
def test_add_widget_simple(): # First, make sure we're at the dashboard page. # (Note: We want the first thing we do in this test function to be a yield, # so that later asserts which aren't contained in yielded functions are not # executed when nose runs this function to acquire the generator.) yield check_we_are_at_dashboard_page # Click 'Add Widget' (also checks that we end up on the 'Create a new # Widget' page) yield click_add_widget # If we click Cancel, do we end up back on the dashboard page? yield click_cancel # Return to Add Widget page yield click_add_widget # Open the username menu, so we can check the links expand_username_menu() # Verify the 'Devices', 'Advanced Options' and 'Manage Account' links yield do_check_link("Devices", splinter_tests.SERVER_URL + "/#/devices") yield do_check_link("Advanced Options", splinter_tests.SERVER_URL + "/#/advanced") yield do_check_link("Manage Account", "https://login.etherios.com/home.do") # 'Cancel' should bring us back to the dashboard yield click_cancel # 'Add Widget' should bring us back there yield click_add_widget # Verify all the other links that should be on this page. for linktext, url in get_general_page_links(): yield do_check_link(linktext, url) # Wait for Angular to catch up to us (specifically, to allow Angular to # fetch the user's devices and populate the selection box) do_sleep() # Test how selecting a gateway changes the error state on the page # TODO Should this go in something like test_add_widget_page? gateway_selection_row = browser.find_by_xpath( # Find the 'select' with name 'device', get its grandparent '//select[@name = "device"]/../..') assert not gateway_selection_row.is_empty() assert gateway_selection_row.first.has_class('has-error') # There should also be some error text near the top of the page # Find the list item with a bold "Gateway:" string inside it err_item_xpath = ("//div[contains(@class, 'alert alert-danger')]/ul/li" "/strong[.='Gateway:']/..") gateway_error = browser.find_by_xpath(err_item_xpath) assert not gateway_error.is_empty() # Check that this item is visible on the page assert gateway_error.first.visible # The error should be 'You need to select a gateway' assert_that("You need to select a gateway", is_in(gateway_error.text)) # If we select a gateway, the has-error class should go away # test_user has only one device, so select value 0 browser.select("device", "0") assert not gateway_selection_row.first.has_class('has-error') # The error should also disappear # The 'Gateway:' error item is only hidden when the value becomes valid, # and not destroyed, so we can reuse the gateway_error variable from above assert not gateway_error.first.visible