def setUp(self):
     self.driver = webdriver.Firefox()
     self.form = ModuleForm(self.driver)
     self.form.get_module(config.PWI_URL + "/edit/gxdindex")
     username = self.driver.find_element_by_name("user")  # finds the user login box
     username.send_keys(config.PWI_LOGIN)  # enters the username
     passwd = self.driver.find_element_by_name("password")  # finds the password box
     passwd.send_keys(config.PWI_PASSWORD)  # enters a valid password
     submit = self.driver.find_element_by_name("submit")  # Find the Login button
     submit.click()  # click the login button
 def setUp(self):
     self.report = Report()
     self.report.WriteReportHeader()
     self.driver = webdriver.Chrome()
     self.form = ModuleForm(self.driver)
     self.form.get_module(config.PWI_URL + "/edit/gxdindex") 
     username = self.driver.find_element_by_name('user')#finds the user login box
     username.send_keys(config.PWI_LOGIN) #enters the username
     passwd = self.driver.find_element_by_name('password')#finds the password box
     passwd.send_keys(config.PWI_PASSWORD) #enters a valid password
     submit = self.driver.find_element_by_name("submit") #Find the Login button
     submit.click() #click the login button
class TestModify(unittest.TestCase):
    """
    @status Test GXD Index browser for the correct fields being cleared
    """

    def setUp(self):
        self.driver = webdriver.Firefox()
        self.form = ModuleForm(self.driver)
        self.form.get_module(config.PWI_URL + "/edit/gxdindex")
        username = self.driver.find_element_by_name("user")  # finds the user login box
        username.send_keys(config.PWI_LOGIN)  # enters the username
        passwd = self.driver.find_element_by_name("password")  # finds the password box
        passwd.send_keys(config.PWI_PASSWORD)  # enters a valid password
        submit = self.driver.find_element_by_name("submit")  # Find the Login button
        submit.click()  # click the login button

    def testClearFields(self):
        """
        @Status tests that when an index record is cleared the correct fields get cleared
        
        """
        driver = self.driver
        form = self.form

        form.enter_value("jnumid", "74162")
        # click the Tab key
        form.press_tab()
        # finds the citation field
        citation = form.get_value("citation")
        print citation
        self.assertEqual(citation, "Abdelwahid E, Cell Tissue Res 2001 Jul;305(1):67-78")
        # finds the marker field
        form.enter_value("marker_symbol", "Bmp2")
        marker_symbol = form.get_value("marker_symbol")
        form.press_tab()
        print marker_symbol
        self.assertEqual(marker_symbol, "Bmp2")
        form.click_search()

        # finds the coded? field
        is_coded = form.get_value("is_coded")

        print is_coded
        self.assertEqual(is_coded, "false")

        # finds the priority field
        priority = form.get_selected_text("_priority_key")

        print priority
        self.assertEqual(priority, "High")

        # finds the conditional mutants field
        conditional = form.get_selected_text("_conditionalmutants_key")

        print conditional
        self.assertEqual(conditional, "Not Specified")

        # finds the created by field
        created_user = form.get_value("createdby_login")

        print created_user
        self.assertEqual(created_user, "MGI_2.97")

        # finds the modified by field
        modified_user = form.get_value("modifiedby_login")  # .find_element_by_css_selector('td')

        print modified_user
        self.assertEqual(modified_user, "MGI_2.97")

        # finds the created by date field
        created_date = form.get_value("creation_date")

        print created_date
        self.assertEqual(created_date, "04/23/2002")

        # finds the created by date field
        modified_date = form.get_value("modification_date")

        print modified_date
        self.assertEqual(modified_date, "04/23/2002")

        # find the table field to check
        table_element = driver.find_element_by_id("indexGrid")
        table = Table(table_element)
        # puts an X in the Prot-sxn by age 7.5 box
        cell = table.get_cell("RT-PCR", "A")
        # cell.click()
        wait.forAngular(driver)
        self.assertEqual(cell.text, "X", "the cell is not checked")

        form.click_clear()  # press the clear button
        # finds the citation field
        citation = form.get_value("citation")
        print citation
        self.assertEqual(citation, "")
        # finds the marker field
        marker_symbol = form.get_value("marker_symbol")
        print marker_symbol
        self.assertEqual(marker_symbol, "")
        # finds the coded? field
        is_coded = form.get_value("is_coded")
        print is_coded
        self.assertEqual(is_coded, "")

        # finds the priority field
        priority = form.get_selected_text("_priority_key")

        print priority
        self.assertEqual(priority, "Search All")

        # finds the conditional mutants field
        conditional = form.get_selected_text("_conditionalmutants_key")

        print conditional
        self.assertEqual(conditional, "Search All")

        # finds the created by field
        created_user = form.get_value("createdby_login")

        print created_user
        self.assertEqual(created_user, "")

        # finds the modified by field
        modified_user = form.get_value("modifiedby_login")  # .find_element_by_css_selector('td')

        print modified_user
        self.assertEqual(modified_user, "")

        # finds the created by date field
        created_date = form.get_value("creation_date")

        print created_date
        self.assertEqual(created_date, "")

        # finds the created by date field
        modified_date = form.get_value("modification_date")

        print modified_date
        self.assertEqual(modified_date, "")

        # find the table field to check
        table_element = driver.find_element_by_id("indexGrid")
        table = Table(table_element)
        # puts an X in the Prot-sxn by age 7.5 box
        cell = table.get_cell("RT-PCR", "A")
        # cell.click()
        wait.forAngular(driver)
        self.assertNotEqual(cell.text, "X", "the cell is not checked")

    def tearDown(self):
        driver = self.driver
        form = self.form
        form.click_clear()
        form.enter_value("jnumid", "225216")
        form.press_tab()
        form.enter_value("marker_symbol", "Bmp2")
        form.press_tab()
        form.click_search()
        form.click_delete()
        driver.close()
class TestModify(unittest.TestCase):
    """
    @status Test GXD Index browser for the correct fields being cleared
    @attention: This will only work on the Chrome browser. Only contains 2 shortcut tests, others can be added later as time permits
    """

    def setUp(self):
        self.report = Report()
        self.report.WriteReportHeader()
        self.driver = webdriver.Chrome()
        self.form = ModuleForm(self.driver)
        self.form.get_module(config.PWI_URL + "/edit/gxdindex") 
        username = self.driver.find_element_by_name('user')#finds the user login box
        username.send_keys(config.PWI_LOGIN) #enters the username
        passwd = self.driver.find_element_by_name('password')#finds the password box
        passwd.send_keys(config.PWI_PASSWORD) #enters a valid password
        submit = self.driver.find_element_by_name("submit") #Find the Login button
        submit.click() #click the login button
        

    def testCtrlAltc(self):
        """
        @Status tests that when an index record is cleared using Ctrl+Alt+c the correct fields are cleared
        
        """
        driver = self.driver
        form = self.form
        action = ActionChains(self.driver)
        form.enter_value('jnumid', '74162')
        # click the Tab key
        form.press_tab()
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        try:
            self.assertEqual(citation, 'Abdelwahid E, Cell Tissue Res 2001 Jul;305(1):67-78')
            self.report.AppendToReport("gxdIdx1-0", "testctrrlaltc", "citation text displays", "correct citation text displays", citation, "Pass", "")
        except Exception:
            self.report.AppendToReport("gxdIdx1-0", "testctrrlaltc", "citation text displays", "correct citation text displays", citation, "Fail", "")
        #finds the marker field
        form.enter_value('marker_symbol', 'Bmp2')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        try:
            self.assertEqual(marker_symbol, 'Bmp2')
            self.report.AppendToReport("gxdIdx1-1", "testctrrlaltc", "marker symbol displays", "correct marker symbol displays", "symbol is ", "Pass", "")
        except Exception:
            self.report.AppendToReport("gxdIdx1-1", "testctrrlaltc", "marker symbol displays", "correct marker symbol displays", "symbol is ", "Fail", "")
        form.click_search()
        time.sleep(2)
        action.key_down(Keys.CONTROL).key_down(Keys.ALT).send_keys('c').key_up(Keys.CONTROL).key_up(Keys.ALT).perform()
        time.sleep(5)
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        self.assertEqual(citation, '')
        #finds the marker field
        marker_symbol = form.get_value('marker_symbol')
        print marker_symbol
        self.assertEqual(marker_symbol, '')
        #finds the coded? field
        is_coded = form.get_value('is_coded')
        
        print is_coded
        self.assertEqual(is_coded, '')
        #finds the priority field
        priority = form.get_selected_text('_priority_key') 
        print priority
        self.assertEqual(priority, 'Search All')
        #finds the conditional mutants field
        conditional = form.get_selected_text('_conditionalmutants_key')
        print conditional
        self.assertEqual(conditional, 'Search All')
        #finds the created by field
        created_user = form.get_value('createdby_login')
        print created_user
        self.assertEqual(created_user, '')
        #finds the modified by field
        modified_user = form.get_value('modifiedby_login')#.find_element_by_css_selector('td')
        print modified_user
        self.assertEqual(modified_user, '')
        #finds the created by date field
        created_date = form.get_value('creation_date')
        print created_date
        self.assertEqual(created_date, '')
        #finds the created by date field
        modified_date = form.get_value('modification_date')
        print modified_date
        self.assertEqual(modified_date, '')
        #find the table field to check
        table_element = driver.find_element_by_id("indexGrid")
        table = Table(table_element)
        #verifies there is no X in the RNA-sxn by age 10.5 box
        cell = table.get_cell(2, 21)
        #cell.click()
        wait.forAngular(driver)
        self.assertEqual(cell.text, '', "the cell is checked")
        
    def testCtrlAlts(self):
        """
        @Status tests that when a reference is entered then Ctrl+Alt+s is pressed the correct results are returned
        
        """
        driver = self.driver
        form = self.form
        actions = ActionChains(self.driver)
        form.enter_value('jnumid', '124809')
        # click the Tab key
        form.press_tab()
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        try:
            self.assertEqual(citation, 'Cheong N, J Biol Chem 2007 Aug 17;282(33):23811-7')
            self.report.AppendToReport("gxdIdx1-2", "testctrrlalts", "Citation is displayed", "correct citation displays", "citation is ", "Pass", "")
        except Exception:
            self.report.AppendToReport("gxdIdx1-2", "testctrrlalts", "Citation is displayed", "correct citation displays", "citation is ", "Fail", "")
        actions.key_down(Keys.CONTROL).key_down(Keys.ALT).send_keys('s').key_up(Keys.CONTROL).key_up(Keys.ALT).perform()
        time.sleep(5)
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        self.assertEqual(citation, 'Cheong N, J Biol Chem 2007 Aug 17;282(33):23811-7')
        #finds the marker field
        marker_symbol = form.get_value('marker_symbol')
        print marker_symbol
        self.assertEqual(marker_symbol, 'Abca3')
        #finds the coded? field
        is_coded = form.get_value('is_coded')
        
        print is_coded
        self.assertEqual(is_coded, 'false')
        #finds the priority field
        priority = form.get_selected_text('_priority_key') 
        print priority
        self.assertEqual(priority, 'Medium')
        #finds the conditional mutants field
        conditional = form.get_selected_text('_conditionalmutants_key')
        print conditional
        self.assertEqual(conditional, 'Not Specified')
        #finds the created by field
        created_user = form.get_value('createdby_login')
        print created_user
        self.assertEqual(created_user, 'terryh')
        #finds the modified by field
        modified_user = form.get_value('modifiedby_login')#.find_element_by_css_selector('td')
        print modified_user
        self.assertEqual(modified_user, 'terryh')
        #finds the created by date field
        created_date = form.get_value('creation_date')
        print created_date
        self.assertEqual(created_date, '10/01/2007')
        #finds the created by date field
        modified_date = form.get_value('modification_date')
        print modified_date
        self.assertEqual(modified_date, '10/01/2007')
        #find the table field to check
        table_element = driver.find_element_by_id("indexGrid")
        table = Table(table_element)
        #verifies there is an X in the Prot-sxn by age 18.5 box
        cell = table.get_cell(1, 37)
        wait.forAngular(driver)
        self.assertEqual(cell.text, 'X', "the cell is checked")   

    def tearDown(self):
        #driver = self.driver
        #form = self.form
        #form.click_clear()
        #form.enter_value('jnumid', '225216')
        #form.press_tab()
        #form.enter_value('marker_symbol', 'Bmp2')
        #form.press_tab()
        #form.click_search()
        #form.click_delete()
        self.report.WriteReportFooter()
        self.report.WriteToFile("GXDIndexEITestResults.html")
        self.driver.quit()
class TestModify(unittest.TestCase):
    """
    @status Test GXD Index browser for ability to modify marker and notes data, later will need to verify created and modified by/dates
    """

    def setUp(self):
        self.driver = webdriver.Firefox()
        self.form = ModuleForm(self.driver)
        self.form.get_module(config.PWI_URL + "/edit/gxdindex") 
        username = self.driver.find_element_by_name('user')#finds the user login box
        username.send_keys(config.PWI_LOGIN) #enters the username
        passwd = self.driver.find_element_by_name('password')#finds the password box
        passwd.send_keys(config.PWI_PASSWORD) #enters a valid password
        submit = self.driver.find_element_by_name("submit") #Find the Login button
        submit.click() #click the login button
        

    def testModMrk(self):
        """
        @Status tests that an index record Marker symbol can be modified
        
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('jnumid', '225216')
        # click the Tab key
        form.press_tab()
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        self.assertEqual(citation, 'Alvarez-Saavedra M, Nat Commun 2014;5():4181')
        #finds the marker field
        form.enter_value('marker_symbol', 'Bmp4')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        self.assertEqual(marker_symbol, 'Bmp4')
        form.click_search()
        self.driver.find_element_by_id('marker_symbol').clear()#clears the marker field
        form.enter_value('marker_symbol', 'Bmp2')#Enter Bmp2 as the marker
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        wait.forAngular(driver)
        form.click_modify()
        marker_symbol = form.get_value('marker_symbol')
        print marker_symbol
        #find the table field to check
        table_element = driver.find_element_by_id("indexGrid")
        table = Table(table_element)
        #puts an X in the Prot-sxn by age 7.5 box
        cell = table.get_cell("prot-sxn", "7.5")
        cell.click()
        wait.forAngular(driver)
        self.assertEqual(cell.text, 'X', "the cell is not checked")

        
    def testModNotes(self):
        """
        @Status tests that the notes field can be modified
        
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('jnumid', '225216')
        # click the Tab key
        form.press_tab()
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        self.assertEqual(citation, 'Alvarez-Saavedra M, Nat Commun 2014;5():4181')
        #finds the marker field
        form.enter_value('marker_symbol', 'Bmp2')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        self.assertEqual(marker_symbol, 'Bmp2')
        form.click_search()
        self.driver.find_element_by_id('comments').clear()#clears the notes field
        form.enter_value('comments', 'A test Comment')#Enter a note in the notes field
        marker_symbol = form.get_value('comments')
        form.press_tab()
        print marker_symbol
        wait.forAngular(driver)
        form.click_modify()
        marker_symbol = form.get_value('comments')
        print marker_symbol
        #find the table field to check
        table_element = driver.find_element_by_id("indexGrid")
        table = Table(table_element)
        #puts an X in the Prot-sxn by age 7.5 box
        cell = table.get_cell("prot-sxn", "7.5")
        cell.click()
        wait.forAngular(driver)
        self.assertEqual(cell.text, 'X', "the cell is not checked")


    def tearDown(self):
        driver = self.driver
        form = self.form
        form.click_clear()
        form.enter_value('jnumid', '225216')
        form.press_tab()
        form.enter_value('marker_symbol', 'Bmp2')
        form.press_tab()
        form.click_search()
        form.click_delete()
        self.driver.close()
 def setUp(self):
     self.driver = webdriver.Firefox() 
     self.form = ModuleForm(self.driver)
     self.form.get_module(config.PWI_URL + "/edit/gxdindex")
class TestSearch(unittest.TestCase):
    """
    @status Test GXD Index browser search using J number, marker symbol, ???
    """

    def setUp(self):
        self.driver = webdriver.Firefox() 
        self.form = ModuleForm(self.driver)
        self.form.get_module(config.PWI_URL + "/edit/gxdindex")
    
    def tearDown(self):
        self.driver.close()
        

    def testJnumSearch(self):
        """
        @Status tests that a basic J number search works
        
        """
        driver = self.driver
        form = self.form
        form.enter_value('jnumid', '173543')
        form.click_search()
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        self.assertEqual(citation, 'Harper J, Proc Natl Acad Sci U S A 2011 Jun 28;108(26):10585-90')
        #finds the marker field
        marker_symbol = form.get_value('marker_symbol')
        print marker_symbol
        self.assertEqual(marker_symbol, '1810065E05Rik')
        #finds the coded? field
        is_coded = form.get_value('is_coded')
        print is_coded
        self.assertEqual(is_coded, 'false')
        #finds the priority field
        priority = form.get_selected_text('_priority_key')
        print priority
        self.assertEqual(priority, 'High')
        #finds the conditional mutants field
        conditional = form.get_selected_text('_conditionalmutants_key')
        print conditional
        self.assertEqual(conditional, 'Conditional')
        #finds the created by field
        created_user = form.get_value('createdby_login')
        print created_user
        self.assertEqual(created_user, 'jx')
        #finds the modified by field
        modified_user = form.get_value('modifiedby_login')#.find_element_by_css_selector('td')
        print modified_user
        self.assertEqual(modified_user, 'jx')
        #finds the created by date field
        created_date = form.get_value('creation_date')
        print created_date
        self.assertEqual(created_date, '07/26/2011')
        #finds the created by date field
        modified_date = form.get_value('modification_date')
        print modified_date
        self.assertEqual(modified_date, '12/12/2011')
        
    def testInvalidJnumSearch(self):
        """
        @Status tests that an invalid J number search gives an error
        
        """
        form = self.form
        form.enter_value('jnumid', "99999999")
        form.press_tab()
        error = form.get_error_message()
        self.assertEqual("No Reference for J Number=J:99999999", error)
        
    def testMarkerSearch(self):
        """
        @Status Tests that a marker symbol search works, verifies the details of the first result listed
        
        """
        form = self.form
        form.enter_value('marker_symbol', 'Pax6')
        form.click_search()
        #finds the J number field
        jnumid = form.get_value('jnumid')
        print jnumid
        self.assertEqual(jnumid, 'J:193837')
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        self.assertEqual(citation, 'Abdelhamed ZA, Hum Mol Genet 2013 Apr 1;22(7):1358-72')
        #finds the coded? field
        is_coded = form.get_value('is_coded')
        print is_coded
        self.assertEqual(is_coded, 'false')
        #finds the priority field
        priority = form.get_selected_text('_priority_key')
        print priority
        self.assertEqual(priority, 'Medium')
        #finds the conditional field
        conditional = form.get_selected_text('_conditionalmutants_key')
        print conditional
        self.assertEqual(conditional, 'Not Applicable')
        #finds the created by field
        created_user = form.get_value('createdby_login')
        print created_user
        self.assertEqual(created_user, 'terryh')
        #finds the modified by field
        modified_user = form.get_value('modifiedby_login')#.find_element_by_css_selector('td')
        print modified_user
        self.assertEqual(modified_user, 'terryh')
        #finds the created by date field
        created_date = form.get_value('creation_date')
        print created_date
        self.assertEqual(created_date, '03/26/2013')
        #finds the created by date field
        modified_date = form.get_value('modification_date')
        print modified_date
        self.assertEqual(modified_date, '03/26/2013')
        
    def testMrkWildcardSearch(self):
        """
        @Status tests that a wildcard search for a marker works
        
        """
        form = self.form
        
        form.enter_value('marker_symbol', 'unc5%')
        form.enter_value('_priority_key', 'low')
        form.click_search()
        
        marker_symbol = form.get_value('marker_symbol')
        self.assertEqual(marker_symbol, 'Unc5a')
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker','Unc5a', 'Unc5a', 'Unc5b', 'Unc5b', 'Unc5b', 'Unc5c', 'Unc5c', 'Unc5c', 'Unc5d', 'Unc5d', 'Unc5d'])
            
    def testCitationWildcardSearch(self):
        """
        @Status tests that a wildcard search for a citation works
        
        """
        form = self.form
        form.enter_value('citation', '%Blood 1991% ')
        form.click_search()
        marker_symbol = form.get_value('marker_symbol')
        self.assertEqual(marker_symbol, 'Ptpn1')
        #finds the citation field
        citation = form.get_value('citation')
        self.assertEqual(citation, 'Yi T, Blood 1991 Nov 1;78(9):2222-8')
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1, the table headers
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1, the marker symbols
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker','Ptpn1', 'Ptpn12', 'Ptpn6', 'Ptpra', 'Ptprc', 'Ptpre', 'Ptprj'])
        
    def testNotesWildcardSearch(self):
        """
        @Status tests that a wildcard search for a noteworks
        
        """
        form = self.form
        form.enter_value('comments', '%slot%')
        form.press_tab()
        form.enter_value('_priority_key', 'High')
        form.press_tab()
        form.enter_value('_conditionalmutants_key', '4834242')
        form.press_tab()
        form.enter_value('is_coded', 'true')
        form.press_tab()
        form.click_search()
        note = form.get_value('comments')
        self.assertEqual(note, 'Some of the northern data was obtained using slot blots.  Age of embryo at noon of plug day not specified in reference.')
        #finds the citation field
        citation = form.get_value('citation')
        self.assertEqual(citation, 'Chianale J, Biochim Biophys Acta 1995 Dec 27;1264(3):369-76')
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1, the table headers
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1, the marker symbols
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        print symbols
        self.assertEqual(symbols, ['Marker','Abcb1a', 'Sdc1', 'Sptb', 'Sptbn1'])
                
    def testWithdrawnMrkSearch(self):
        """
        @Status tests that a search for a withdrawn marker gives an error
        """
        form = self.form
        form.enter_value('marker_symbol', 'dw')
        form.press_tab()
        error = form.get_error_message()
        # error message will display current symbol for dw
        self.assertIn("Pou1f1", error )
        # marker entry should be cleared
        marker_symbol = form.get_value('marker_symbol')
        self.assertEqual(marker_symbol, '')
        
    def testInvalidMrkSearch(self):
        """
        @Status tests that an error message is displayed when invalid marker symbol entered
        
        """
        form = self.form
        form.enter_value('marker_symbol', 'test12345')
        form.press_tab()
        error = form.get_error_message()
        self.assertEqual(error, "Invalid marker symbol test12345")
        # marker entry should be cleared
        marker_symbol = form.get_value('marker_symbol')
        self.assertEqual(marker_symbol, '')
        
    def testQTLErrorMsg(self):
        """
        @Status tests that an error message is displayed when selecting a QTL
        
        """
        form = self.form
        form.enter_value('marker_symbol', 'iba1')
        form.press_tab()
        error = form.get_error_message()
        self.assertEqual(error, "You selected a QTL type marker: Iba1")
        # marker should still be selected, even though error is displayed
        marker_symbol = form.get_value('marker_symbol')
        self.assertEqual(marker_symbol, 'Iba1')
        
    def testHeritPhenoMrkErrorMsg(self):
        """
        @Status tests that an error(Warning) message is displayed when selecting a heritable phenotypic marker
        
        """
        form = self.form
        form.enter_value('marker_symbol', 'act')
        form.press_tab()
        error = form.get_error_message()
        self.assertEqual(error, "You selected a heritable phenotypic marker: act")
        # marker should still be selected, even though warning error is displayed
        marker_symbol = form.get_value('marker_symbol')
        self.assertEqual(marker_symbol, 'act')
            
    def testMultipleMrkSearch(self):
        """
        @Status tests that a multiple marker search works
        @bug test needs to be written
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('marker_symbol', 't')
        form.press_tab()
        wait.forAngular(driver)
        
        # verify that display with two markers is shown
        mrkrows = driver.find_elements_by_css_selector(".markerSelections td")
        print mrkrows
        markers = [r.text for r in mrkrows]
        self.assertEqual(len(markers), 2)
        self.assertEqual(markers[0], "T, brachyury, Chr 17, Band")
        self.assertEqual(markers[1], "t, t-complex, Chr 17, Band")
        
        #form.press_enter()
        mrkrows[0].click()
        wait.forAngular(driver)
        
        # marker T should be selected
        marker_symbol = form.get_value('marker_symbol')
        self.assertEqual(marker_symbol, 'T')
    
    def testMultiFieldSearch(self):
        """
        @Status tests that searching by priority, conditional, and coded fields gives the correct results
        
        """
        form = self.form
        form.enter_value('_priority_key', 'Medium')
        form.press_tab()
        form.enter_value('_conditionalmutants_key', 'Conditional (minor)')
        form.press_tab()
        form.enter_value('is_coded', 'Yes')
        form.press_tab()
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker', 'Acta2', 'Aqp2', 'Clec1b', 'Emcn', 'Fgf8', 'Lmx1b', 'Lyve1', 'Pdpn', 'Postn', 'Tagln', 'Upk1b', 'Upk3a', 'Upk3b', 'Wnt7a'])

    def testCreatededBySearch(self):
        """
        @Status tests that searching the Created by user field gives the correct results
        
        """
        form = self.form
        form.enter_value('_priority_key', 'High')
        form.enter_value('_conditionalmutants_key', 'Conditional')
        form.enter_value('is_coded', 'Yes')
        form.enter_value('createdby_login', 'ijm')
        form.press_tab()
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker', 'Hnf1a', 'Runx1', 'Timp1', 'Tnc'])
                        
    def testModifiedBySearch(self):
        """
        @Status tests that searching the Modified by user field gives the correct results
        
        """
        form = self.form
        form.enter_value('_priority_key', 'Medium')
        form.enter_value('_conditionalmutants_key', 'Conditional')
        form.enter_value('is_coded', 'Yes')
        form.enter_value('modifiedby_login', 'ijm')
        form.press_tab()
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker', 'Acta2', 'Fabp7', 'Hand1', 'Mbp'])
      
    
    def testCreateDateSearch(self):
        """
        @Status tests that searching by created date gives the correct results
        
        """
        form = self.form
        form.enter_value('creation_date', '05/06/2015')
        form.press_tab()
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker','Mbp', 'Sst'])
            
    def testModifyDateSearch(self):
        """
        @Status tests that searching by modified date gives the correct results
        
        """
        form = self.form
        form.enter_value('modification_date', '05/06/2015')
        form.press_tab()
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker', 'Emp1', 'Gcg', 'Gjb1', 'Gjc1', 'Mbp', 'Sst', 'Zdbf2'])
            
    def testLessThanDateSearch(self):
        """
        @Status tests that searching by less than created by date gives the correct results
        
        """
        form = self.form
        form.enter_value('_priority_key', 'Medium')
        form.press_tab()
        form.enter_value('_conditionalmutants_key', 'Conditional (minor)')
        form.press_tab()
        form.enter_value('is_coded', 'No')
        form.press_tab()
        form.enter_value('creation_date', '<05/06/2009')
        form.press_tab()
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker', 'En1', 'En2', 'Fgf17', 'Fgf8', 'Gbx2', 'Otx2', 'Spry1', 'Wnt1'])
            
    def testLessThanEqualDateSearch(self):
        """
        @Status tests that searching by less than created by date gives the correct results
        
        """
        form = self.form
        form.enter_value('_priority_key', 'Medium')
        form.press_tab()
        form.enter_value('_conditionalmutants_key', 'Conditional (minor)')
        form.press_tab()
        form.enter_value('is_coded', 'Yes')
        form.press_tab()
        form.enter_value('creation_date', "<=09/28/2010")
        form.press_tab()
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker', 'Clec1b', 'Fgf8', 'Lmx1b', 'Lyve1', 'Pdpn', 'Wnt7a'])
            
            
    def testGreaterThanDateSearch(self):
        """
        @Status tests that searching by greater than created by date gives the correct results
        
        """
        form = self.form
        form.enter_value('_priority_key', 'Medium')
        form.press_tab()
        form.enter_value('_conditionalmutants_key', 'Conditional (minor)')
        form.press_tab()
        form.enter_value('is_coded', 'Yes')
        form.press_tab()
        form.enter_value('creation_date', ">05/10/2015")
        form.press_tab()
        wait.forAngular(self.driver)
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker', 'Acta2', 'Aqp2', 'Emcn', 'Postn', 'Tagln', 'Upk1b', 'Upk3a', 'Upk3b'])
            
    def testGreaterThanEqualDateSearch(self):
        """
        @Status tests that searching by greater than or equal to created by date gives the correct results
        
        """
        form = self.form
        form.enter_value('_priority_key', 'Medium')
        form.press_tab()
        form.enter_value('_conditionalmutants_key', 'Conditional (minor)')
        form.press_tab()
        form.enter_value('is_coded', 'Yes')
        form.press_tab()
        form.enter_value('creation_date', ">=11/10/2015")
        form.press_tab()
        wait.forAngular(self.driver)
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker', 'Acta2', 'Aqp2', 'Emcn', 'Postn', 'Tagln', 'Upk1b', 'Upk3a', 'Upk3b'])
            
            
    def testBetweenDateSearch(self):
        """
        @Status tests that searching by inclusive dates gives the correct results
        
        """
        form = self.form
        form.enter_value('_priority_key', 'Medium')
        form.press_tab()
        form.enter_value('_conditionalmutants_key', 'Conditional')
        form.press_tab()
        form.enter_value('is_coded', 'Yes')
        form.press_tab()
        form.enter_value('creation_date', "10/01/2015..12/01/2015")
        form.press_tab()
        wait.forAngular(self.driver)
        form.click_search()#click the search button
        #find the search results table
        results_table = self.driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker', 'Flrt3', 'Ntn1', 'Pecam1', 'Slit1', 'Tlx1'])
            
          
                  
    def testSearchIndex(self):
        """
        @Status tests that an index record(s) can be searched
        """
        driver = self.driver
        form = self.form
        #find the Index grid
        table_element = driver.find_element_by_id("indexGrid")
        table = Table(table_element)
        #puts an X in the Prot-wm by age 7 box
        cell = table.get_cell("prot-wm", "7")
        cell.click()
        #puts an X in the Prot-wm by age 8 box
        cell = table.get_cell("prot-wm", "8")
        cell.click()
        wait.forAngular(driver)
        form.click_search()#click the search button
        #find the search results table
        results_table = driver.find_element_by_id("resultsTable")
        table = Table(results_table)
        #Iterate and print the search results headers
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        #print column 1
        symbols_cells = table.get_column_cells('Marker')
        symbols = iterate.getTextAsList(symbols_cells)
        self.assertEqual(symbols, ['Marker','Adgre1', 'Cdh5', 'Cdx4', 'Eng', 'Fgf8', 'Foxa2', 'Gata6', 'Itga2b', 'Kdr', 'Kdr', 'Kdr', 'Kdr', 'Lrp2', 'Nanog', 'Pdgfra', 'Pecam1', 'Pou3f1', 'Ptprc', 'T', 'T', 'Tal1', 'Tek'])
            
    def testResultsTable(self):
        """
        An example of getting data from the results table using
            Table class
            
        NOTE: this is only for example purposes. Not a real test
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('jnumid', '121946')
        form.press_tab()
        
        form.click_search()
        
        results_table = driver.find_element_by_id("indexGrid")
        table = Table(results_table)
        
        header_cells = table.get_header_cells()
        print iterate.getTextAsList(header_cells)
        # print row 1
        cells = table.get_row_cells(1)
        print iterate.getTextAsList(cells)
        # single cell
        cell = table.get_cell("RNA-WM", "10.5")
        print cell.text
        # empty cell
        cell = table.get_cell("prot-sxn", "A")
class Test(unittest.TestCase):
    """
    @status Test GXD Index browser for ability to modify marker and notes data, later will need to verify created and modified by/dates
    """

    def setUp(self):
        self.driver = webdriver.Firefox()
        self.form = ModuleForm(self.driver)
        self.form.get_module(config.PWI_URL + "/edit/gxdindex") 
        username = self.driver.find_element_by_name('user')#finds the user login box
        username.send_keys(config.PWI_LOGIN) #enters the username
        passwd = self.driver.find_element_by_name('password')#finds the password box
        passwd.send_keys(config.PWI_PASSWORD) #enters a valid password
        submit = self.driver.find_element_by_name("submit") #Find the Login button
        submit.click() #click the login button
        

    def testSelectedNotes(self):
        """
        @Status tests that when you select an option for the notes field the correct option is added/displayed in the notes field, all options are tested
        
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('jnumid', '225216')
        # click the Tab key
        form.press_tab()
        form.enter_value('marker_symbol', 'Bmp4')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        self.assertEqual(marker_symbol, 'Bmp4')
        form.click_search()
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Activated")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "The antibody used recognizes the activated form of the protein.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Cleaved")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "The antibody used recognizes the cleaved form of the protein.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Phosphorylated")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "The antibody used recognizes the phosphorylated form of the protein.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Ab/probe spec.")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "The specificity of the antibody/probe used was not detailed; both/all family members have been annotated.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Ab/probe spec. MGI ID")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "The antibody/probe specificity was not detailed and may recognize a related gene; (MGI:) has also been annotated.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("microRNA")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "The mature microRNA is encoded at multiple sites in the genome.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Supplementary")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "Results are in the supplementary material.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Section or WM")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "Reference does not indicate whether specimen is a section or whole mount.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Range")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "Authors state that expression was examined on dpc *-*; not all stages are detailed.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Primer spec")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "Primer specificity was not detailed and may amplify a related gene; several/all family members have been annotated.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Primer spec MGI ID")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "Primer specificity was not detailed and may amplify a related gene; (MGI:) has also been annotated.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Immunoprecipitated")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "The protein was immunoprecipitated prior to Western blotting.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Dot Blot")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "Northern data was obtained from a dot blot.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Enzymatic act")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "Enzymatic activity was used to detect gene expression.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Discrepancies")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "There are discrepancies between the text and the figure legend as to the age of the tissue/embryo.")
        
        form.get_value("comments")
        driver.find_element_by_id("clearNotesButton").click()
        Select(driver.find_element_by_id("noteSelect")).select_by_visible_text("Fractionated")
        notefield = form.get_value('comments')
        self.assertEqual(notefield, "The material used in the Western blot was fractionated.")
        
        
    def testAgeNotSpecified(self):
        """
        @Status tests that the notes field adds proper text when Age Not Specified button is clicked
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('jnumid', '225216')
        # click the Tab key
        form.press_tab()
        #finds the marker field
        form.enter_value('marker_symbol', 'Bmp2')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        self.assertEqual(marker_symbol, 'Bmp2')
        form.click_search()
        self.driver.find_element_by_id('comments').clear()#clears the notes field
        self.driver.find_element_by_id("ageNotSpecifiedButton").click()
        agenote = form.get_value('comments')#Get what text is in the notes field
        self.assertEqual(agenote, "Age of embryo at noon of plug day not specified in reference.", "The note is incorrect")
        
    def testAgeNormalized(self):
        """
        @Status tests that the notes field adds proper text when Age Normalized button is clicked
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('jnumid', '225216')
        # click the Tab key
        form.press_tab()
        #finds the marker field
        form.enter_value('marker_symbol', 'Bmp2')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        self.assertEqual(marker_symbol, 'Bmp2')
        form.click_search()
        self.driver.find_element_by_id('comments').clear()#clears the notes field
        self.driver.find_element_by_id("ageNormalizedButton").click()
        agenote = form.get_value('comments')#Get what text is in the notes field
        self.assertEqual(agenote, "Age normalized so that noon of plug day = E0.5.", "The note is incorrect")
        
    def testAgeAssigned(self):
        """
        @Status tests that the notes field properly adds text when Age Assigned button is clicked
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('jnumid', '225216')
        # click the Tab key
        form.press_tab()
        #finds the marker field
        form.enter_value('marker_symbol', 'Bmp2')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        self.assertEqual(marker_symbol, 'Bmp2')
        form.click_search()
        self.driver.find_element_by_id('comments').clear()#clears the notes field
        self.driver.find_element_by_id("ageAssignedButton").click()
        agenote = form.get_value('comments')#Get what text is in the notes field
        self.assertEqual(agenote, "Age assigned by curator based on morphological criteria supplied by authors.", "The note is incorrect")
        

    def tearDown(self):
        driver = self.driver
        form = self.form
        #form.click_clear()
        #form.enter_value('jnumid', '225216')
        #form.press_tab()
        #form.enter_value('marker_symbol', 'Bmp2')
        #form.press_tab()
        #form.click_search()
        #form.click_delete()
        self.driver.quit()
class TestAdd(unittest.TestCase):
    """
    @status Test GXD Index browser for ability to add an index
    """

    def setUp(self):
        self.driver = webdriver.Firefox()
        self.form = ModuleForm(self.driver)
        self.form.get_module(config.PWI_URL + "/edit/gxdindex") 
        username = self.driver.find_element_by_name('user')#finds the user login box
        username.send_keys(config.PWI_LOGIN) #enters the username
        passwd = self.driver.find_element_by_name('password')#finds the password box
        passwd.send_keys(config.PWI_PASSWORD) #enters a valid password
        submit = self.driver.find_element_by_name("submit") #Find the Login button
        submit.click() #click the login button
        

    def testAddIndex(self):
        """
        @Status tests that an index record can be added
        
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('jnumid', '225216')
        # click the Tab key
        form.press_tab()
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        self.assertEqual(citation, 'Alvarez-Saavedra M, Nat Commun 2014;5():4181')
        #finds the marker field
        form.enter_value('marker_symbol', 'Bmp2')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        self.assertEqual(marker_symbol, 'Bmp2')
        #find the table field to check
        table_element = driver.find_element_by_id("indexGrid")
        table = Table(table_element)
        #puts an X in the Prot-sxn by age 7.5 box
        cell = table.get_cell("prot-sxn", "7.5")
        cell.click()
        wait.forAngular(driver)
        self.assertEqual(cell.text, 'X', "the cell is not checked")
        form.click_add()#click the add button

    def testDeleteIndex(self):
        """
        @Status tests that an index record can be deleted
        
        """
        driver = self.driver
        form = self.form
        
        form.enter_value('jnumid', '225216')
        # click the Tab key
        form.press_tab()
        #finds the citation field
        citation = form.get_value('citation')
        print citation
        self.assertEqual(citation, 'Alvarez-Saavedra M, Nat Commun 2014;5():4181')
        #finds the marker field
        form.enter_value('marker_symbol', 'Bmp2')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        self.assertEqual(marker_symbol, 'Bmp2')
        #find the table field to check
        table_element = driver.find_element_by_id("indexGrid")
        table = Table(table_element)
        #puts an X in the Prot-sxn by age 7.5 box
        cell = table.get_cell("prot-sxn", "7.5")
        cell.click()
        wait.forAngular(driver)
        self.assertEqual(cell.text, 'X', "the cell is not checked")
        form.click_modify()
        form.click_delete()#click the delete button
        
        
    def testJnumMrkErrMsgs(self):
        """
        @Status tests that the correct error messages are displayed when entering an invalid J number and when entering an invalid Marker
        
        """
        driver = self.driver
        form = self.form
        form.enter_value('jnumid', '000000')
        # click the Tab key
        form.press_tab()
        #Get the error message that is displayed
        jnum_error = form.get_error_message()
        self.assertEqual(jnum_error, "No Reference for J Number=J:000000", 'error message not displayed')
        #finds the marker field
        form.enter_value('marker_symbol', 'ffffff')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        #Get the error message that is displayed
        mrk_error = form.get_error_message()
        self.assertEqual(mrk_error, 'Invalid marker symbol ffffff')

    def testPriorityErrMsg(self):
        """
        @Status tests that the correct error message is displayed when not selecting a priority
        
        """
        driver = self.driver
        form = self.form
        wait.forAngular(driver)
        form.enter_value('jnumid', '144307')
        # click the Tab key
        form.press_tab()
        #finds the marker field
        form.enter_value('marker_symbol', 'zyx')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        #press the enter key
        driver.find_element_by_id("addButton").click()
        wait.forAngular(driver)
        #Get the error message that is displayed
        priority_error = form.get_error_message()
        print priority_error
        self.assertEqual(priority_error, '(psycopg2.InternalError) Priority Required')

    def testStageErrMsg(self):
        """
        @Status tests that the correct error message is displayed when not selecting any stage
        
        """
        driver = self.driver
        form = self.form
        wait.forAngular(driver, '5')
        form.enter_value('jnumid', '225216')
        # click the Tab key
        form.press_tab()
        #finds the marker field
        form.enter_value('marker_symbol', 'Gata1')
        marker_symbol = form.get_value('marker_symbol')
        form.press_tab()
        print marker_symbol
        #finds the marker field
        form.enter_value('_priority_key', 'Low')
        priority_option = form.get_value('_priority_key')
        form.press_tab()
        print priority_option
        #self.assertEqual(priority_option, '74716')
        #press the enter key
        form.click_add()
        
        
        #Get the error message that is displayed
        stage_error = form.get_error_message()
        print stage_error
        self.assertEqual(stage_error, 'No stages have been selected for this record')    
        
        
        table = driver.find_element_by_id("resultsTable")
        table.find_elements_by_tag_name("tr")[1].click()
        wait.forAngular(driver)
        form.click_delete()
    
    def tearDown(self):
        driver = self.driver
        form = self.form
        form.click_clear()
        form.enter_value('jnumid', '225216')
        form.press_tab()
        form.enter_value('marker_symbol', 'Gata1')
        form.press_tab()
        form.click_search()
        form.click_delete()
        driver.close()