def test_animator_jump(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # There must be an image loaded with more than one channel to see the animator. Util.load_image(self,driver, "TWHydra_CO2_1line.image.fits" ) # Set the animator to jump self._setAnimatorToJump( driver ); # Save the preferences self._savePreferences(driver ) # Find the wrap radio button in the animator settings and click it wrapButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "ChannelWrapRadioButton"))) self._setChecked( driver, wrapButton, True ) # Restore the preferences self._restorePreferences( driver ) time.sleep( timeout ) # Verify the animator jump end behavior is checked jumpButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='qx.ui.form.RadioButton']/div[text()='Jump']/following-sibling::div"))) self._verifyChecked( driver, jumpButton )
def test_toolbar_hide(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).click( imageWindow).perform() time.sleep( timeout ) # Find the preferences button on the menu bar and click it. menuBar = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Menu.MenuBar']"))) #self.assertIsNotNone( menuBar, "Could not find the menu bar") preferencesButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Preferences']/.."))) #self.assertIsNotNone( preferencesButton, "Could not find div with text Preferences") ActionChains(driver).click(preferencesButton).perform() # Click the show button on the sub menu. showButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div/div[text()='Show']/.."))) ActionChains(driver).click( showButton).perform() showToolButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Show Tool Bar']/.."))) ActionChains(driver).click( showToolButton).perform() time.sleep( timeout ) # Verify the toolbar is NOT visible toolVisible = self._isToolbarVisible( driver ) self.assertFalse( toolVisible, "Tool bar was not hidden") # Save the preferences self._savePreferences( driver ) # Show the toolbar # Find the preferences button on the menu bar and click it. preferencesButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Preferences']/.."))) ActionChains(driver).click(preferencesButton).perform() # Click the show tool bar button on the sub menu. ActionChains(driver).send_keys( Keys.ARROW_DOWN ).send_keys( Keys.ARROW_RIGHT ).send_keys( Keys.ARROW_DOWN ).send_keys( Keys.ARROW_DOWN ).send_keys( Keys.ENTER ).perform() time.sleep( timeout ) #Verify the toolbar is now visible toolBar = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Menu.ToolBar']"))) # Click the restore sessions button self._clickSessionButton( driver ) self._clickSessionRestoreButton( driver ) # Select tSnapshotPreferences in the restore combo box self._selectRestoreSnapshot( driver, "tSnapshotPreferences") # Hit the restore button self._restoreSnapshot( driver ) # Close the restore dialog self._closeRestore( driver ) time.sleep( timeout ) # Verify the toolbar is hidden again toolVisible = self._isToolbarVisible( driver) self.assertFalse( toolVisible, "Tool bar was not hidden with restore state")
def layout_custom(self, driver, rows, cols ): timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).click( imageWindow ) # Find the layout button on the menu bar and click it. self._clickLayoutButton( driver ) # Find the layout custom button in the submenu and click it. customLayoutButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Custom Layout']"))) ActionChains(driver).click( customLayoutButton ).perform() # Get the row count spin and set its value. rowSpin = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[starts-with(@id,'customLayoutRows')]/input"))) rowSpin.send_keys( Keys.BACK_SPACE ) rowSpin.send_keys( str(rows) ) # Get the column count spin and set its value. colSpin = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[starts-with(@id,'customLayoutCols')]/input"))) colSpin.send_keys( str(cols) ) colSpin.send_keys( Keys.ARROW_LEFT ) colSpin.send_keys( Keys.BACK_SPACE ) # Close the custom layout dialog closeButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[starts-with(@id,'customLayoutOK')]"))) ActionChains(driver).click(closeButton).perform() time.sleep(timeout)
def test_rangeMethod(self): driver = self.driver timeout = selectBrowser._getSleep() #Load a default image Util.load_image( self, driver, "aH.fits") #Show the image settings Util.openSettings( self, driver, "Image", True ) # Navigate to Contour tab of the Histogram Settings self._clickContourTab( driver ) # Set a minimum contour level of 0.1 and a maximum contour level of 0.9 self._typeText( driver, "imageContourLevelMin", 0.1 ) self._typeText( driver, "imageContourLevelMax", 0.9 ) # Change the level count to 3. self._setLevelCount( driver, 3 ) # Hit the Add/Update ContourSet button self._clickAddContourSetButton( driver ) # Check that there is now a Tab called Default under Contour Sets self._clickDefaultContourSetTab( driver ) # Check that we have levels 0.1, 0.5, 0.9 levels = self._getLevels( driver, "contourLevelListDefault" ) self.assertEqual( len(levels), 3, "Three contour levels were not generated") self.assertEqual( levels[0], str(0.1), "First contour was not 0.1") self.assertEqual( levels[1], str(0.5), "Second contour was not 0.5") self.assertEqual( levels[2], str(0.9), "Third contour was not 0.9")
def add_window(unittest, driver): timeout = selectBrowser._getSleep() # Click the Window button windowButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='qx.ui.toolbar.MenuButton']/div[text()='Window']/.." ))) ActionChains(driver).click(windowButton).perform() # Look for the add button in the submenu. addButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div/div[text()='Add']/.."))) ActionChains(driver).click(addButton).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() # Check that we now have a generic empty window in the display and that the window count has gone up by one. emptyWindow = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowGenericPlugin']" ))) ActionChains(driver).click(emptyWindow).perform() return emptyWindow
def test_animator_jump(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Set the animator to jump self._setAnimatorToJump( driver ); # Save the preferences self._savePreferences(driver ) # Find the wrap radio button in the animator settings and click it wrapButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='qx.ui.form.RadioButton']/div[text()='Wrap']/following-sibling::div"))) self.assertIsNotNone( wrapButton, "Could not find wrap button in settings") self._setChecked( driver, wrapButton, True ) # Restore the preferences self._restorePreferences( driver ) time.sleep( timeout ) # Verify the animator jump end behavior is checked jumpButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='qx.ui.form.RadioButton']/div[text()='Jump']/following-sibling::div"))) self.assertIsNotNone( jumpButton, "Could not find jump button in settings") self._verifyChecked( driver, jumpButton )
def test_load_images(self): driver = self.driver timeout = selectBrowser._getSleep() # Load a specific image. imageWindow = Util.load_image(self, driver, "aH.fits") time.sleep( timeout ) Util.load_image( self, driver, "aJ.fits") time.sleep( timeout ) Util.load_image( self, driver, "N15693D.fits") time.sleep( timeout ) Util.load_image( self, driver, "Orion.cont.image.fits") time.sleep( timeout ) Util.load_image( self, driver, "Orion.methanol.cbc.contsub.image.fits") time.sleep( timeout ) Util.load_image( self, driver, "TWHydra_CO2_1line.image.fits") time.sleep( timeout ) Util.load_image( self, driver, "br1202_wide.image") time.sleep( timeout ) Util.load_image( self, driver, "TWHydra_CO3_2line.image") time.sleep( timeout ) Util.load_image( self, driver, "TWHydra_cont1.3mm.image") time.sleep( timeout ) Util.load_image( self, driver, "v2.0_ds2_l000_13pca_map20.fits") time.sleep( timeout ) #Find the image animator and verify that there are 9 images loaded upperBoundText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@id='ImageUpperBoundSpin']/input"))) driver.execute_script( "arguments[0].scrollIntoView(true);", upperBoundText) imageCount = upperBoundText.get_attribute("value") print "Image Count: ", imageCount self.assertEqual( imageCount, str(9), "Wrong number of images were loaded")
def test_histogramRemoveImage(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Load an image Util.load_image( self, driver, "Default") # Click on the Data->Close->Image button to close the image imageWindow = driver.find_element_by_xpath( "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']") ActionChains(driver).double_click( imageWindow ).perform() dataButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Data']/.."))) ActionChains(driver).click( dataButton ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() # Find and select the Histogram window histWindow = self._getHistogramWindow( driver ) ActionChains(driver).click( histWindow ).perform() time.sleep( timeout ) # Click the settings button to expose the settings self._openHistogramSettings( driver ) # Check that the histogram values are restored to default values newMaxZoomValue = self._getTextValue( driver, "histogramZoomMaxValue") print "Zoom max value=", newMaxZoomValue self.assertEqual( float(newMaxZoomValue), 1, "Default values were not restored after image removal")
def test_histogramAddImage(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Load an image Util.load_image(self, driver, "Default") # Find and select the histogram histWindow = self._getHistogramWindow(driver) ActionChains(driver).click( histWindow ).perform() # Click the settings button to expose the settings self._openHistogramSettings( driver ) # Get the max zoom value of the first image maxZoomValue = self._getTextValue( driver, "histogramZoomMaxValue") print "First image maxZoomValue:", maxZoomValue # Load a different image in the same window Util.load_image(self, driver, "aH.fits") time.sleep( timeout ) # Check that the new max zoom value updates newMaxZoomValue = self._getTextValue( driver, "histogramZoomMaxValue") self.assertNotEqual(float(newMaxZoomValue), float(maxZoomValue), "The histogram did not update when a new image was loaded.") print "Second image maxZoomValue:", newMaxZoomValue
def test_animatorRemoveLink(self): driver = self.driver browser = selectBrowser._getBrowser() timeout = 2 * selectBrowser._getSleep() # Locate the image window on the page; ensures browser is fully loaded imageWindow = WebDriverWait(driver, 30).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Load an image with multiple channels so that the channel animator will show. Util.load_image(self, driver, "Default") # Make sure the animation window is enabled by clicking an element within the window channelText = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "ChannelIndexText"))) ActionChains(driver).click(channelText).perform() # Remove link from main image window to Animator linkMenuButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='qx.ui.toolbar.MenuButton']/div[text()='Links...']" ))) ActionChains(driver).click(linkMenuButton).perform() Util.remove_main_link(self, driver, imageWindow) # Load another image Util.load_image(self, driver, "aH.fits") self.animatorsAtDefault()
def test_animatorRemoveImage(self): driver = self.driver timeout = 2 * selectBrowser._getSleep() # Load two image Util.load_image(self, driver, "Default") Util.load_image(self, driver, "aH.fits") # Click on the Data->Close->Image button to close the image. imageWindow = driver.find_element_by_xpath( "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']") ActionChains(driver).click(imageWindow).perform() dataButton = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Data']/.."))) ActionChains(driver).click(dataButton).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() time.sleep(timeout) dataButton = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Data']/.."))) ActionChains(driver).click(dataButton).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() self.animatorsAtDefault()
def test_percentileMethod(self): driver = self.driver timeout = selectBrowser._getSleep() #Load a default image Util.load_image(self, driver, "aH.fits") #Show the image settings Util.openSettings(self, driver, "Image", True) # Navigate to Contour tab of the Image Settings self._clickContourTab(driver) # Set a minimum contour level of 10 and a maximum contour level of 90 self._typeText(driver, "imageContourLevelMin", 20) self._typeText(driver, "imageContourLevelMax", 90) # Change the level count to 3. self._setLevelCount(driver, 3) # Hit the Add/Update ContourSet button self._clickAddContourSetButton(driver) # Check that there is now a Tab called Default under Contour Sets self._clickDefaultContourSetTab(driver)
def test_negativeRegionWidth(self): driver = self.driver timeout = selectBrowser._getSleep() # Load a specific image. imageWindow = Util.load_image(self, driver, "Default") time.sleep( timeout ) # Load a specific region in the image. Util.load_image( self, driver, "OrionMethanolRegion.crtf") time.sleep( 4 ) #Open the image settings #Open the stack tab Util.openSettings( self, driver, "Image", True ) time.sleep(4) Util.clickTab( driver, "Regions" ) #Change the width to -40 and check for an error. widthText = driver.find_element_by_xpath("//div[@id='RectangleRegionWidth']/input") driver.execute_script( "arguments[0].scrollIntoView(true);", widthText ) Util._changeElementText(self, driver, widthText, -10) widthError = driver.find_element_by_xpath("//div[@id='RectangleRegionWidth']/div[contains(text(),'Range error:')]") self.assertIsNotNone( widthError, "No error was posted") time.sleep( timeout ) #Change the width to 40 and check that the error is not there Util._changeElementText(self, driver, widthText, 40 ); try: widthError = driver.find_element_by_xpath("//div[@id='RectangleRegionWidth']/div[contains(text(),'Range error:')]") self.assertTrue( False, "Should not be able to find a range error.") except Exception: print "Good, the error disappeared!"
def test_analysis_saveRestore(self): driver = self.driver timeout = selectBrowser._getSleep() #For later use, determine the number of DisplayWindows. windowList = driver.find_elements_by_xpath( "//div[@qxclass='skel.widgets.Window.DisplayDesktop']") windowCount = len(windowList) print "Window Count=", windowCount # Find the session button on the menu bar and click it. self._clickSessionButton(driver) # Find the save session button in the submenu and click it. self._clickSessionSaveButton(driver) # The save popup should be visible. Make sure preferences and data are not checked; # layout is checked. self._setSaveOptions(driver, False, True, False) # Type in tSnapshotLayout for the save name. self._setSaveName(driver, "tSnapshotLayout") # Hit the save button self._saveSnapshot(driver) # Close the dialog self._closeSave(driver) # Change to an image layout layoutButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Layout']/.."))) ActionChains(driver).click(layoutButton).perform() imageLayoutButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Image Layout']/.."))) ActionChains(driver).click(imageLayoutButton).perform() # Click the restore sessions button self._clickSessionButton(driver) self._clickSessionRestoreButton(driver) # Select tSnapshotLayout in the combo box self._selectRestoreSnapshot(driver, "tSnapshotLayout") # Hit the restore button self._restoreSnapshot(driver) # Close the restore dialog self._closeRestore(driver) time.sleep(timeout) # Verify the window count is the same newWindowList = driver.find_elements_by_xpath( "//div[@qxclass='skel.widgets.Window.DisplayDesktop']") newWindowCount = len(newWindowList) print "New Window Count=", newWindowCount self.assertEqual(windowCount, newWindowCount, "Window count changed with restore")
def test_animatorIncreaseFrame(self): driver = self.driver timeout = selectBrowser._getSleep() # Open a test image so we have something to animate Util.load_image( self, driver, "aH.fits") Util.load_image( self, driver, "aJ.fits") Util.load_image( self, driver, "Default") # Go to the first channel value and record the frame value self._getFirstValue( driver, "Channel" ) firstChannelValue = self._getCurrentValue( driver, "Channel" ) # Find the increment by one button on the Channel Animator Tape Deck and click it self._getNextValue( driver, "Channel" ) # Check that the channel text box value is now 1 currChannelValue = self._getCurrentValue( driver, "Channel") print "Check increase frame..." print "oldChannelValue= 0 newChannelValue=", currChannelValue self.assertEqual( int(currChannelValue), int(firstChannelValue)+1, "Failed to increment Channel Animator") # Record the first image value self._getFirstValue( driver, "Image" ) firstImageValue = self._getCurrentValue( driver, "Image" ) # Find the increment by one button on the Animator Tape Deck and click it self._getNextValue( driver, "Image" ) # Check that the image text box value is now 1 currImageValue = self._getCurrentValue( driver, "Image" ) print "Check increase image..." print "oldImageValue=", firstImageValue, "newImageValue=", currImageValue self.assertEqual( int(currImageValue), int(firstImageValue)+1, "Failed to increment the Image Animator")
def test_globalIsGlobal(self): driver = self.driver timeout = selectBrowser._getSleep() #Load a default image Util.load_image(self, driver, "Default") Util.load_image(self, driver, "aJ.fits") Util.load_image(self, driver, "aH.fits") #Store the old colormap oldMapName = self._getColorMapName(driver) print "Old map name=", oldMapName #Choose a new color map self._chooseNewColorMap(driver) newMapName = self._getColorMapName(driver) print "New map name=", newMapName self.assertTrue(oldMapName != newMapName, "Color map name did not change") #Animate through the images and make sure they are all using the #new color map. for i in range(0, 2): self._nextImage(driver) imageMapName = self._getColorMapName(driver) print "Image name=", imageMapName self.assertTrue(imageMapName == newMapName, "Image name was not changed")
def test_minimize_restore(self): driver = self.driver timeout = selectBrowser._getSleep() # Find a window capable of loading an image and select the window imageWindow = WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).click( imageWindow ).perform() time.sleep( timeout ) # Click the Window button windowButton = driver.find_element_by_xpath( "//div[text()='Window']/..") ActionChains(driver).click( windowButton ).perform() # Look for the minimize button in the submenu. minimizeButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div/div[text()='Minimize']/.."))) ActionChains(driver).click( minimizeButton ).perform() # Verify that there is a Restore button on the status bar and no DisplayWindowImage. restoreButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='qx.ui.toolbar.MenuButton']/div[contains(text(), 'Restore: CasaImageLoader')]/.."))) # Restore the window. Verify the restore button is gone from the status bar and there is a DisplayWindowImage ActionChains(driver).click( restoreButton ).perform() #Check that the clipping menu item is no longer available try: restoreLabel = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='qx.ui.toolbar.MenuButton']/div[contains(text(), 'Restore: CasaImageLoader')]"))) self.assertTrue( False, "Should not be able to locate the restore image loader button") except Exception: print "Test restore button was successfully removed" imageWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']")))
def _clickLayoutButton(self, driver): timeout = selectBrowser._getSleep() time.sleep( timeout ) # Find the layout button on the menu bar and click it. layoutButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Layout']/.."))) self.assertIsNotNone( layoutButton, "Could not find layout button on the menu bar") ActionChains(driver).click( layoutButton ).perform()
def test_newProfileExisting(self): driver = self.driver timeout = selectBrowser._getSleep() print "Timeout=",timeout #Load two images Util.load_image(self, driver, "Orion.methanol.cbc.contsub.image.fits" ) time.sleep(1) Util.load_image(self, driver, "TWHydra_CO2_1line.image.fits" ) time.sleep( 1) # Show the profile view self._showProfile( driver ) time.sleep(2) #Open the profile settings to the Profiles tab. profileWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowProfile']"))) ActionChains(driver).click( profileWindow ).perform() time.sleep(2) Util.openSettings( self, driver, "Profile", True ) time.sleep(2) Util.clickTab( driver, "Profiles" ) #Get the profiles combo and count how many are listed. Since #the mode is auto generate and current there should be just one. self._checkProfileCount( driver, 1) #Turn off auto generate. Util.clickTab( driver, "Profiles" ) self._setAutoGenerate( driver, False ) time.sleep( timeout ) #Store the image rest frequency. restFrequency = self._getRestFrequency( driver ) #Select the other image and test the rest frequency changes to match #the selected image comboPath = "//div[starts-with(@id,'ProfileSelectedImage')]" imageCombo = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, comboPath))) driver.execute_script( "arguments[0].scrollIntoView(true);", imageCombo ) ActionChains(driver).click( imageCombo ).perform() ActionChains(driver).click( imageCombo).send_keys(Keys.UP).send_keys( Keys.ENTER).perform() time.sleep( timeout ) newRestFrequency = self._getRestFrequency( driver ) self.assertNotEqual( restFrequency, newRestFrequency, "Image rest frequency did not change") #Hit the new profile button. self._hitNew( driver ) time.sleep( 4 ) #Verify that we now have two profiles. self._checkProfileCount( driver, 2 ) #Turn on auto generate Util.clickTab( driver, "Profiles" ) self._setAutoGenerate( driver, True ) time.sleep( timeout ) #Verify that we are back to one profile. self._checkProfileCount( driver, 1 )
def test_rangeMethod(self): driver = self.driver timeout = selectBrowser._getSleep() #Load a default image Util.load_image(self, driver, "aH.fits") #Show the image settings Util.openSettings(self, driver, "Image", True) # Navigate to Contour tab of the Histogram Settings self._clickContourTab(driver) # Set a minimum contour level of 0.1 and a maximum contour level of 0.9 self._typeText(driver, "imageContourLevelMin", 0.1) self._typeText(driver, "imageContourLevelMax", 0.9) # Change the level count to 3. self._setLevelCount(driver, 3) # Hit the Add/Update ContourSet button self._clickAddContourSetButton(driver) # Check that there is now a Tab called Default under Contour Sets self._clickDefaultContourSetTab(driver) # Check that we have levels 0.1, 0.5, 0.9 levels = self._getLevels(driver, "contourLevelListDefault") self.assertEqual(len(levels), 3, "Three contour levels were not generated") self.assertEqual(levels[0], str(0.1), "First contour was not 0.1") self.assertEqual(levels[1], str(0.5), "Second contour was not 0.5") self.assertEqual(levels[2], str(0.9), "Third contour was not 0.9")
def test_profileRegion(self): driver = self.driver timeout = selectBrowser._getSleep() #Load a default image Util.load_image( self, driver, "Orion.methanol.cbc.contsub.image.fits") time.sleep( timeout ) #Load a region for the image Util.load_image( self, driver, "OrionMethanolRegion.crtf") time.sleep( timeout ) self._showProfile( driver ) time.sleep( timeout ) #Open the profile settings to the Profiles tab. profileWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowProfile']"))) ActionChains(driver).click( profileWindow ).perform() time.sleep( timeout ) Util.openSettings( self, driver, "Profile", True ) time.sleep( timeout ) Util.clickTab( driver, "Profiles" ) time.sleep( timeout ) #Check that there is a region we are profiling regionCombo = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "ProfileSelectedRegion"))) driver.execute_script( "arguments[0].scrollIntoView(true);", regionCombo ) nameDiv = regionCombo.find_element_by_xpath( ".//div/div") regionName = nameDiv.get_attribute( "innerHTML").strip() print "Region is ",regionName self.assertTrue( regionName != "None", "Expected a region to be profiled")
def test_maximize_restore(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Find and select the colormap window. colorWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowColormap']"))) ActionChains(driver).click(colorWindow).perform(); #For later use, determine the number of DisplayWindows. windowCount = Util.get_window_count( self, driver ) print "Window Count=", windowCount # Click the Window button windowButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='qx.ui.toolbar.MenuButton']/div[text()='Window']/.."))) ActionChains(driver).click(windowButton).perform() # Look for the maximize button in the submenu. maximizeButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Maximize']/.."))) ActionChains(driver).click(maximizeButton).perform() # Verify that there is single colormap window. colorWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowColormap']"))) # Now right click the context menu to restore the colormap window ActionChains(driver).context_click(colorWindow).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() time.sleep( timeout ) # Verify that there are exactly the same number of windows as was there originally and the colormap window is present. newWindowCount = Util.get_window_count( self, driver ) print "New Window Count=", newWindowCount self.assertEqual( windowCount, newWindowCount, "Window count has changed") colorWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowColormap']")))
def test_animatorIncreaseFrame(self): driver = self.driver timeout = selectBrowser._getSleep() # Open a test image so we have something to animate Util.load_image(self, driver, "aH.fits") Util.load_image(self, driver, "aJ.fits") Util.load_image(self, driver, "Default") # Go to the first channel value and record the frame value self._getFirstValue(driver, "Channel") firstChannelValue = self._getCurrentValue(driver, "Channel") # Find the increment by one button on the Channel Animator Tape Deck and click it self._getNextValue(driver, "Channel") # Check that the channel text box value is now 1 currChannelValue = self._getCurrentValue(driver, "Channel") print "Check increase frame..." print "oldChannelValue= 0 newChannelValue=", currChannelValue self.assertEqual(int(currChannelValue), int(firstChannelValue) + 1, "Failed to increment Channel Animator") # Record the first image value self._getFirstValue(driver, "Image") firstImageValue = self._getCurrentValue(driver, "Image") # Find the increment by one button on the Animator Tape Deck and click it self._getNextValue(driver, "Image") # Check that the image text box value is now 1 currImageValue = self._getCurrentValue(driver, "Image") print "Check increase image..." print "oldImageValue=", firstImageValue, "newImageValue=", currImageValue self.assertEqual(int(currImageValue), int(firstImageValue) + 1, "Failed to increment the Image Animator")
def test_histogramAddImage(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Load an image Util.load_image(self, driver, "Default") # Find and select the histogram histWindow = self._getHistogramWindow(driver) ActionChains(driver).click(histWindow).perform() # Click the settings button to expose the settings self._openHistogramSettings(driver) # Get the max zoom value of the first image maxZoomValue = self._getTextValue(driver, "histogramZoomMaxValue") print "First image maxZoomValue:", maxZoomValue # Load a different image in the same window Util.load_image(self, driver, "aH.fits") time.sleep(timeout) # Check that the new max zoom value updates newMaxZoomValue = self._getTextValue(driver, "histogramZoomMaxValue") self.assertNotEqual( float(newMaxZoomValue), float(maxZoomValue), "The histogram did not update when a new image was loaded.") print "Second image maxZoomValue:", newMaxZoomValue
def test_layout_image(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']")) ) # Find the layout button on the menu bar and click it. self._clickLayoutButton(driver) # Find the layout image button in the submenu and click it. imageLayoutButton = driver.find_element_by_xpath("//div[text()='Image Layout']/..") # imageLayoutButton = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div[text()='Image Layout']/.."))) ActionChains(driver).click(imageLayoutButton).perform() time.sleep(timeout) # Check that there is an Image Window imageWindow = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']")) ) # Check that there are no other Windows windowCount = Util.get_window_count(self, driver) self.assertEqual(windowCount, 1, "Image Layout should have only one window")
def test_channelAnimatorChangeImage(self): driver = self.driver timeout = selectBrowser._getSleep() # Load two images # The images have different numbers of channels Util.load_image( self, driver, "Default") Util.load_image( self, driver, "aH.fits") # Go to the first image self._getFirstValue( driver, "Image") # Go to the last channel of the image self._getLastValue( driver, "Channel") # Get the last channel value of the first image firstImageChannelValue = self._getCurrentValue( driver, "Channel" ) print "firstImageChannelValue=",firstImageChannelValue # Go to the next image self._getNextValue( driver, "Image" ) # Go to the last channel of the image self._getLastValue( driver, "Channel") # Get the channel upper spin box value of the second image # Check that the upper spin box value updated # Get the channel upper spin box value of the first image secondImageChannelValue = self._getCurrentValue( driver, "Channel" ) print "First image channel ", firstImageChannelValue," second image channel ",secondImageChannelValue self.assertNotEqual( int(secondImageChannelValue), int(firstImageChannelValue), "Channel value did not update after changing image in window")
def test_clip100(self): driver = self.driver timeout = selectBrowser._getSleep() # Load a specific image. imageWindow = Util.load_image(self, driver, "Default") time.sleep( timeout ) # Store the minimum clip value minClipText = driver.find_element_by_xpath("//div[@id='clipMinIntensity']/input") driver.execute_script( "arguments[0].scrollIntoView(true);", minClipText ) minClip = minClipText.get_attribute( "value") print "Min intensity", minClip # Press the 100% clip button ActionChains(driver).double_click( imageWindow ).perform() clippingButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Clipping']/.."))) ActionChains(driver).click( clippingButton ).send_keys(Keys.ARROW_RIGHT ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN ).send_keys(Keys.ENTER).perform() time.sleep( timeout ) # Make sure the minimum clip value goes down. newMinClip = minClipText.get_attribute( "value") print "New min intensity", newMinClip self.assertTrue( float(newMinClip) < float(minClip), "Minimum clip value did not go down")
def test_sameViewTwice(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Get the image window count and make sure it is non-zero imageWindowList = driver.find_elements_by_xpath("//div[@qxclass='skel.widgets.Window.DisplayWindowImage']") imageWindowCount = len( imageWindowList ) print "Original image count ", imageWindowCount self.assertGreater( imageWindowCount, 0, "There are not any images") # Locate an image window and bring up the right-context menu, # changing to a CasaImageLoader. imageWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).context_click( imageWindow ).perform(); # Change the plugin to another image loader ActionChains(driver).send_keys( Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() time.sleep( timeout ) # Verify that the image count has remained the same imageWindowList2 = driver.find_elements_by_xpath("//div[@qxclass='skel.widgets.Window.DisplayWindowImage']") newImageWindowCount = len( imageWindowList2 ) print "New Image Count ", newImageWindowCount self.assertEqual( imageWindowCount, newImageWindowCount, "Image window count did not remain the same")
def test_zoomPercentage(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Load an image Util.load_image(self, driver, "Orion.methanol.cbc.contsub.image.fits") time.sleep(4) # Show the profile view self._showProfile(driver) time.sleep(4) #Open the profile settings to the Range tab. profileWindow = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowProfile']"))) ActionChains(driver).click(profileWindow).perform() Util.openSettings(self, driver, "Profile", True) time.sleep(2) Util.clickTab(driver, "Range") # Look for the min and max zoom percentages and check their values. minZoomPercent = Util._getTextValue(self, driver, 'profileZoomMinPercent') print "Min zoom percent=", minZoomPercent maxZoomPercent = Util._getTextValue(self, driver, 'profileZoomMaxPercent') print "Max zoom percent=", maxZoomPercent self.assertEqual(float(minZoomPercent), 0, "Min zoom percent was not correct") self.assertEqual(float(maxZoomPercent), 100, "Max zoom percent was not correct") # Find the min and max zoom values. Change their values. minText = driver.find_element_by_id("profileZoomMinValue") driver.execute_script("arguments[0].scrollIntoView(true);", minText) maxText = driver.find_element_by_id("profileZoomMaxValue") driver.execute_script("arguments[0].scrollIntoView(true);", maxText) Util._changeElementText(self, driver, minText, '4') Util._changeElementText(self, driver, maxText, '36') time.sleep(timeout) # Get the new min and max zoom values. newMinZoomPercent = Util._getTextValue(self, driver, "profileZoomMinPercent") newMaxZoomPercent = Util._getTextValue(self, driver, "profileZoomMaxPercent") print "New min zoom=", newMinZoomPercent print "New max zoom=", newMaxZoomPercent self.assertEqual(float(newMinZoomPercent), 10, "Min zoom percent was not correct") self.assertEqual(float(newMaxZoomPercent), 90, "Max zoom percent was not correct")
def test_percentileMethod(self): driver = self.driver timeout = selectBrowser._getSleep() #Load a default image Util.load_image( self, driver, "aH.fits") #Show the image settings Util.openSettings( self, driver, "Image", True ) # Navigate to Contour tab of the Image Settings self._clickContourTab( driver ) # Set a minimum contour level of 10 and a maximum contour level of 90 self._typeText( driver, "imageContourLevelMin", 20 ) self._typeText( driver, "imageContourLevelMax", 90 ) # Change the level count to 3. self._setLevelCount( driver, 3 ) # Hit the Add/Update ContourSet button self._clickAddContourSetButton( driver ) # Check that there is now a Tab called Default under Contour Sets self._clickDefaultContourSetTab( driver )
def test_deleteImageFromRegion(self): driver = self.driver timeout = selectBrowser._getSleep() # Load a specific image. imageWindow = Util.load_image(self, driver, "Default") time.sleep( timeout ) # Load a specific region in the image. Util.load_image( self, driver, "OrionMethanolRegion.crtf") time.sleep( 4 ) #Open the image settings #Open the regions tab Util.openSettings( self, driver, "Image", True ) time.sleep(4) Util.clickTab( driver, "Regions" ) #Verify that there is one region in the region list. self._checkRegionCount( driver, 1 ); # Click on the Data->Close->Image button to close the image. ActionChains(driver).double_click( imageWindow ).perform() dataButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Data']/.."))) ActionChains(driver).click( dataButton ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() time.sleep( timeout )
def test_channelAnimatorChangeImage(self): driver = self.driver timeout = selectBrowser._getSleep() # Load two images # The images have different numbers of channels Util.load_image(self, driver, "Default") Util.load_image(self, driver, "aH.fits") # Go to the first image self._getFirstValue(driver, "Image") # Go to the last channel of the image self._getLastValue(driver, "Channel") # Get the last channel value of the first image firstImageChannelValue = self._getCurrentValue(driver, "Channel") print "firstImageChannelValue=", firstImageChannelValue # Go to the next image self._getNextValue(driver, "Image") # Go to the last channel of the image self._getLastValue(driver, "Channel") # Get the channel upper spin box value of the second image # Check that the upper spin box value updated # Get the channel upper spin box value of the first image secondImageChannelValue = self._getCurrentValue(driver, "Channel") print "First image channel ", firstImageChannelValue, " second image channel ", secondImageChannelValue self.assertNotEqual( int(secondImageChannelValue), int(firstImageChannelValue), "Channel value did not update after changing image in window", )
def test_coordinateChange(self): driver = self.driver timeout = selectBrowser._getSleep() #Load an image with a tabular axis Util.load_image( self, driver, "aJ.fits") time.sleep( 3 ) #Open the image settings tab Util.openSettings( self, driver, "Image", True ) time.sleep( timeout ) #Get the old coordinateSystem systemText = driver.find_element_by_xpath("//div[@id='ImageCoordinateSystem']/input") driver.execute_script( "arguments[0].scrollIntoView(true);", systemText ) oldSystem = systemText.get_attribute('value') print "Old system=", oldSystem #Change the coordinate system csCombo = driver.find_element_by_xpath("//div[@id='ImageCoordinateSystem']/div") driver.execute_script( "arguments[0].scrollIntoView(true);", csCombo ) ActionChains(driver).click(csCombo).send_keys( Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN ).send_keys( Keys.ARROW_DOWN).send_keys( Keys.ENTER).perform() time.sleep( timeout ) #Verify the coordinate system is changed systemText = driver.find_element_by_xpath("//div[@id='ImageCoordinateSystem']/input") driver.execute_script( "arguments[0].scrollIntoView(true);", systemText ) newSystem = systemText.get_attribute( 'value') print "New system=",newSystem self.assertTrue( newSystem != oldSystem, "Coordinate system did not change")
def test_unitChange(self): driver = self.driver timeout = selectBrowser._getSleep() #Load a 2D image Util.load_image( self, driver, "aH.fits") #Get the old units unitCombo = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "colorImageUnits"))) driver.execute_script( "arguments[0].scrollIntoView(true);", unitCombo ) unitText = unitCombo.find_element_by_xpath( ".//div/div") oldUnits = unitText.text print "Old units=", oldUnits #Change the units ActionChains(driver).click(unitCombo).send_keys( Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN ).send_keys( Keys.ENTER).perform() time.sleep( timeout ) #Verify the units are changed. unitCombo = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "colorImageUnits"))) driver.execute_script( "arguments[0].scrollIntoView(true);", unitCombo ) unitText = unitCombo.find_element_by_xpath( ".//div/div") newUnits = unitText.text print "New units=",newUnits self.assertTrue( newUnits != oldUnits, "Color map units did not change")
def test_globalIsGlobal(self): driver = self.driver timeout = selectBrowser._getSleep() #Load a default image Util.load_image( self, driver, "Default") Util.load_image( self, driver, "aJ.fits") Util.load_image( self, driver, "aH.fits") #Store the old colormap oldMapName = self._getColorMapName( driver ) print "Old map name=",oldMapName #Choose a new color map self._chooseNewColorMap( driver ) newMapName = self._getColorMapName( driver ) print "New map name=", newMapName self.assertTrue( oldMapName != newMapName, "Color map name did not change") #Animate through the images and make sure they are all using the #new color map. for i in range(0,2): self._nextImage( driver ) imageMapName = self._getColorMapName( driver ) print "Image name=",imageMapName self.assertTrue( imageMapName == newMapName, "Image name was not changed")
def _chooseNewColorMap(self, driver ): timeout = selectBrowser._getSleep() colorMapCombo = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "colorMapName"))) driver.execute_script( "arguments[0].scrollIntoView(true);", colorMapCombo ) ActionChains(driver).click(colorMapCombo).send_keys( Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN ).send_keys( Keys.ENTER).perform() time.sleep( timeout )
def test_groupRename(self): driver = self.driver timeout = selectBrowser._getSleep() #Load images Util.load_image( self, driver, "Orion.methanol.cbc.contsub.image.fits") Util.load_image( self, driver, "Orion.cont.image.fits") Util.load_image( self, driver, "TWHydra_CO2_1line.image.fits") time.sleep( 2 ) #Open the image settings #Open the stack tab Util.openSettings( self, driver, "Image", True ) Util.clickTab( driver, "Stack" ) #Turn off auto select autoSelectCheck = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "autoSelectImages"))) ActionChains(driver).click( autoSelectCheck ).perform() #Group the bottom two images. secondItem = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Image.Stack.TreeItem']/div[text()='Orion.cont.image.fits']/.."))) actions = ActionChains( driver).key_down(Keys.SHIFT).click( secondItem ) actions.key_up( Keys.SHIFT ).perform() #Click the group check box. groupCheck = WebDriverWait( driver, 10).until( EC.presence_of_element_located((By.ID, "stackGroupImages"))) ActionChains(driver).click( groupCheck ).perform() time.sleep(2) #Change the name of the group to twoImageRGB & verify that there is a tree node with that name.. nameText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[starts-with(@id, 'stackLayerName')]"))) Util._changeElementText(self, driver, nameText, "twoImageRGB") WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[contains(text(),'twoImageRGB')]")))
def _getLastValue(self, driver): timeout = selectBrowser._getSleep() lastValueButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@class='qx-toolbar']/div[@qxclass='qx.ui.toolbar.Button'][5]"))) self.assertIsNotNone( lastValueButton, "Could not find button to go to the last valid value") driver.execute_script( "arguments[0].scrollIntoView(true);", lastValueButton) ActionChains(driver).click( lastValueButton ).perform() time.sleep( timeout )
def test_animator_to_casaimageloader(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Get the animation window count and make sure it is non-zero animWindowList = driver.find_elements_by_xpath("//div[@qxclass='skel.widgets.Window.DisplayWindowAnimation']") animWindowCount = len( animWindowList ) self.assertGreater( animWindowCount, 0, "There are not any animators") # Get the image window count imageWindowList = driver.find_elements_by_xpath("//div[@qxclass='skel.widgets.Window.DisplayWindowImage']") imageWindowCount = len( imageWindowList ) # Locate an animator window and bring up the right-context menu, # changing to a CasaImageLoader. Util.animation_to_image_window( self, driver ) time.sleep( timeout ) # Verify that the animation count has gone down by one and the image count # has increased by one. animWindowList = driver.find_elements_by_xpath("//div[@qxclass='skel.widgets.Window.DisplayWindowAnimation']") newAnimWindowCount = len( animWindowList ) self.assertEqual( animWindowCount - 1, newAnimWindowCount, "Animation count did not decrease") imageWindowList = driver.find_elements_by_xpath("//div[@qxclass='skel.widgets.Window.DisplayWindowImage']") newImageWindowCount = len( imageWindowList ) self.assertEqual( newImageWindowCount - 1, imageWindowCount, "Image window count did not increase")
def test_histogramSelectRegionDelete(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Load an image Util.load_image(self, driver, "Default") time.sleep(2) # Load a region Util.load_image(self, driver, "OrionMethanolRegion.crtf") time.sleep(2) # Find and select the Histogram window histWindow = self._getHistogramWindow(driver) ActionChains(driver).click(histWindow).perform() # Click the settings button to expose the settings self._openHistogramSettings(driver) # Open the Selection settings for the Histogram window selectionTab = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='qx.ui.tabview.TabButton']/div[contains(text(),'Selection')]/.." ))) driver.execute_script("arguments[0].scrollIntoView(true);", selectionTab) ActionChains(driver).click(selectionTab).perform() #Choose selected region as the foot print. regionId = "Histogram2DFootPrintRegion" selectRegionRadio = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.ID, "Histogram2DFootPrintRegion"))) driver.execute_script("arguments[0].scrollIntoView(true);", selectRegionRadio) ActionChains(driver).click(selectRegionRadio).perform() time.sleep(timeout) selectRegion = Util.isCheckedRadio(self, selectRegionRadio) print "Select region=", selectRegion self.assertEqual(selectRegion, True, "Histogram not displaying current region") #Delete the region ActionChains(driver).double_click(imageWindow).perform() dataButton = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Data']/.."))) ActionChains(driver).click(dataButton).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ENTER).perform() time.sleep(timeout)
def test_animatorRemoveImage(self): driver = self.driver timeout = selectBrowser._getSleep() # Load an image Util.load_image(self, driver, "Default") # Click on the Data->Close->Image button to close the image. imageWindow = driver.find_element_by_xpath( "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']") ActionChains(driver).double_click(imageWindow).perform() dataButton = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Data']/.."))) ActionChains(driver).click(dataButton).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() # Get the channel upper spin value upperBoundText = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@id='ChannelUpperBoundSpin']/input"))) driver.execute_script("arguments[0].scrollIntoView(true);", upperBoundText) upperBound = upperBoundText.get_attribute("value") # Make sure the Animation window is enabled by clicking an element within the window channelText = driver.find_element_by_id("ChannelIndexText") ActionChains(driver).click(channelText).perform() # Show the Image Animator animateToolBar = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='qx.ui.toolbar.MenuButton']/div[text()='Animate']" ))) ActionChains(driver).click(animateToolBar).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ENTER).perform() time.sleep(timeout) # Find and click the upper spin box imageUpperBoundText = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@id='ImageUpperBoundSpin']/input"))) driver.execute_script("arguments[0].scrollIntoView(true);", imageUpperBoundText) # Get the image upper spin value imageCount = imageUpperBoundText.get_attribute("value") print "Image count=", imageCount # Check that the Animator is reset to default settings self.assertEqual( int(imageCount), 0, "Image Animator did not reset after the image was removed") self.assertEqual( int(upperBound), 0, "Channel Animator did not reset after the image was removed")
def test_histogramChangeImage(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Load two images in the same image window Util.load_image(self, driver, "Default") Util.load_image(self, driver, "aH.fits") time.sleep(timeout) # Find and select the histogram histWindow = self._getHistogramWindow(driver) ActionChains(driver).click(histWindow).perform() # Click the settings button to expose the settings self._openHistogramSettings(driver) time.sleep(timeout) # Record the Histogram max zoom value of the second image secondMaxZoomValue = Util._getTextValue(self, driver, "histogramZoomMaxValue") print "Second image maxZoomValue:", secondMaxZoomValue # Find and click on the animation window animWindow = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowAnimation']" ))) ActionChains(driver).click(animWindow).perform() # Make sure the animation window is enabled by clicking an element within the window imageText = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "ImageIndexText"))) ActionChains(driver).click(imageText).perform() # Find the first value button and click the button firstValueButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "ImageTapeDeckFirstValue"))) driver.execute_script("arguments[0].scrollIntoView(true);", firstValueButton) ActionChains(driver).click(firstValueButton).perform() time.sleep(timeout) # Record the Histogram max zoom value of the first image firstMaxZoomValue = Util._getTextValue(self, driver, "histogramZoomMaxValue") print "First image maxZoomValue:", firstMaxZoomValue # Check that the Histogram updates its values self.assertNotEqual( float(firstMaxZoomValue), float(secondMaxZoomValue), "Histogram did not update when the image was switched in the image window." )
def tearDown(self): # Close the browser self.driver.close() # Allow browser to fully close before continuing timeout = 2 * selectBrowser._getSleep() time.sleep(timeout) # Close the session and delete temporary files self.driver.quit()
def _nextImage(self, driver): timeout = selectBrowser._getSleep() incrementButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "ImageTapeDeckIncrement"))) driver.execute_script("arguments[0].scrollIntoView(true);", incrementButton) ActionChains(driver).click(incrementButton).perform() time.sleep(timeout)
def tearDown(self): # Close the browser self.driver.close() # Allow browser to fully close before continuing timeout = 2*selectBrowser._getSleep() time.sleep(timeout) # Close the session and delete temporary files self.driver.quit()
def test_analysis_saveRestore(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).click( imageWindow).perform() time.sleep( timeout ) #For later use, determine the number of DisplayWindows. windowList = driver.find_elements_by_xpath("//div[@qxclass='skel.widgets.Window.DisplayWindow']") windowCount = len( windowList ) print "Window Count=", windowCount # Find the session button on the menu bar and click it. self._clickSessionButton( driver ) # Find the save session button in the submenu and click it. self._clickSessionSaveButton( driver ) # The save popup should be visible. Make sure preferences and data are not checked; # layout is checked. self._setSaveOptions( driver, False, True, False) # Type in tSnapshotLayout for the save name. self._setSaveName( driver, "tSnapshotLayout") # Hit the save button self._saveSnapshot( driver ) # Close the dialog self._closeSave( driver ) # Change to an image layout layoutButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Layout']/.."))) ActionChains(driver).click(layoutButton).perform() imageLayoutButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Image Layout']/.."))) ActionChains(driver).click( imageLayoutButton).perform() # Click the restore sessions button self._clickSessionButton( driver ) self._clickSessionRestoreButton( driver ) # Select tSnapshotLayout in the combo box self._selectRestoreSnapshot( driver, "tSnapshotLayout") # Hit the restore button self._restoreSnapshot( driver ) # Close the restore dialog self._closeRestore( driver ) time.sleep( timeout ) # Verify the window count is the same newWindowList = driver.find_elements_by_xpath("//div[@qxclass='skel.widgets.Window.DisplayDesktop']") newWindowCount = len( newWindowList ) print "New Window Count=", newWindowCount self.assertEqual( windowCount, newWindowCount, "Window count changed with restore")
def test_replaceImageLoader(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 30).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Change to a 2,1 layout Util.layout_custom(self, driver, 2, 1) time.sleep(timeout) # Change the first window, which should be empty to an image window emptyWindow = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowGenericPlugin']" ))) ActionChains(driver).context_click(emptyWindow).perform() # Change the plugin to an image loader ActionChains(driver).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ARROW_RIGHT).send_keys( Keys.ENTER).perform() time.sleep(timeout) # There should now be 2 Image Loader Windows imageWindows = driver.find_elements( By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']") imageWindowCount = len(imageWindows) print "Image window count=", imageWindowCount self.assertEqual(imageWindowCount, 2, "Image window count was not 2") time.sleep(timeout) # Now change the second image loader window to something else ActionChains(driver).click(imageWindows[1]).perform() ActionChains(driver).context_click(imageWindows[1]).perform() # Change the plugin to an image loader ActionChains(driver).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ARROW_RIGHT).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() time.sleep(timeout) #Verify there is now just one image loader imageWindows = driver.find_elements( By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']") imageWindowCount = len(imageWindows) print "Image window count=", imageWindowCount self.assertEqual(imageWindowCount, 1, "Image window count was not 1") time.sleep(timeout) # Finally, click on the first image window and verify we can load an image # in it ActionChains(driver).click(imageWindows[0]).perform() Util.load_image(self, driver, "aJ.fits")
def layout_custom(unittest, driver, rows, cols): timeout = selectBrowser._getSleep() # Now right click the toolbar toolBar = driver.find_element_by_xpath( "//div[@qxclass='skel.widgets.Menu.ToolBar']") actionChains = ActionChains(driver) actionChains.context_click(toolBar).perform() # Find and click the customize button customizeButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Customize...']/.."))) ActionChains(driver).click(customizeButton).perform() # Uncheck clipping layoutButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Layout']/preceding-sibling::div/div"))) styleAtt = layoutButton.get_attribute("style") print "Style", styleAtt if not "checked.png" in styleAtt: print "Clipping checked" layoutParent = layoutButton.find_element_by_xpath('..') ActionChains(driver).click(layoutParent).perform() # Close the toolbar closeButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, "//div[text()='Close']/.."))) ActionChains(driver).click(closeButton).perform() # Click the customize button on the toolbar customLayoutButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Custom Layout']"))) ActionChains(driver).click(customLayoutButton).perform() # Get the row count spin and set its value. rowSpin = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[starts-with(@id,'customLayoutRows')]/input"))) rowSpin.send_keys(Keys.BACK_SPACE) rowSpin.send_keys(str(rows)) # Get the column count spin and set its value. colSpin = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[starts-with(@id,'customLayoutCols')]/input"))) colSpin.send_keys(str(cols)) colSpin.send_keys(Keys.ARROW_LEFT) colSpin.send_keys(Keys.BACK_SPACE) # Close the custom layout dialog closeButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[starts-with(@id,'customLayoutOK')]"))) ActionChains(driver).click(closeButton).perform() time.sleep(timeout)
def test_generateMode(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Load three images Util.load_image(self, driver, "Orion.methanol.cbc.contsub.image.fits") time.sleep(1) Util.load_image(self, driver, "TWHydra_CO2_1line.image.fits") time.sleep(1) Util.load_image(self, driver, "Orion.cont.image.fits") time.sleep(4) # Show the profile view self._showProfile(driver) time.sleep(4) #Open the profile settings to the Profiles tab. profileWindow = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowProfile']"))) ActionChains(driver).click(profileWindow).perform() time.sleep(2) Util.openSettings(self, driver, "Profile", True) time.sleep(2) Util.clickTab(driver, "Profiles") #Get the profiles combo and count how many are listed. Since #the mode is current there should be just one. self._checkProfileCount(driver, 1) #Change the generate mode to all Util.clickTab(driver, "Profiles") time.sleep(1) genSelect = driver.find_element_by_id("profileGenerateMode") driver.execute_script("arguments[0].scrollIntoView(true);", genSelect) ActionChains(driver).click(genSelect).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() #There should now be three profiles loaded. time.sleep(2) self._checkProfileCount(driver, 3) #Change the generate mode to all except single plane. Util.clickTab(driver, "Profiles") ActionChains(driver).click(genSelect).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ENTER).perform() #There should now be two profiles loaded. time.sleep(6) self._checkProfileCount(driver, 2)
def test_animatorAddLink(self): driver = self.driver timeout = selectBrowser._getSleep() browser = selectBrowser._getBrowser() time.sleep(2) # Load image in a separate window, but make sure it has at least # one channel. imageWindow2 = Util.load_image_different_window( self, driver, "TWHydra_CO2_1line.image.fits") time.sleep(2) # Make sure the animation window is enabled by clicking an element within the window animWindow = driver.find_element_by_xpath( "//div[@qxclass='skel.widgets.Window.DisplayWindowAnimation']") ActionChains(driver).click(animWindow).perform() # Navigate to view links from the Animator settings linkMenuButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='qx.ui.toolbar.MenuButton']/div[text()='Links...']" ))) ActionChains(driver).click(linkMenuButton).perform() # Add link from the Animator to the image Util.link_second_image(self, driver, imageWindow2) ActionChains(driver).send_keys(Keys.ESCAPE).perform() # Find and click the upper spin box upperBoundText = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@id='ChannelUpperBoundSpin']/input"))) driver.execute_script("arguments[0].scrollIntoView(true);", upperBoundText) # Check that the animator updates upperBound = upperBoundText.get_attribute("value") print "Upper bound ", upperBound self.assertNotEqual(int(upperBound), 0, "Channel animator did not update to linked image") # Show the Image Animator by loading a second image. Util.load_image_windowIndex(self, driver, "aH.fits", 2) # Find and click the upper spin box imageUpperBoundText = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@id='ImageUpperBoundSpin']/input"))) driver.execute_script("arguments[0].scrollIntoView(true);", imageUpperBoundText) # Get the image upper spin value imageCount = imageUpperBoundText.get_attribute("value") # Check that the Image Animator updates self.assertEqual( int(imageCount), 1, "Image Animator did not update after image was linked")
def test_zoom(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Load an image Util.load_image(self, driver, "Default") #Find and select the histogram window histWindow = self._getHistogramWindow(driver) ActionChains(driver).click(histWindow).perform() # Click the settings button to expose the settings. self._openHistogramSettings(driver) # Look for the min and max zoom values and store their values. minZoomValue = self._getTextValue(driver, "histogramZoomMinValue") print "Min zoom=", minZoomValue maxZoomValue = self._getTextValue(driver, "histogramZoomMaxValue") print "Max zoom=", maxZoomValue # Find the min and max zoom percentages. Decrease their values. minPercentText = driver.find_element_by_id("histogramZoomMinPercent") driver.execute_script("arguments[0].scrollIntoView(true);", minPercentText) minZoomPercent = minPercentText.get_attribute("value") maxPercentText = driver.find_element_by_id("histogramZoomMaxPercent") maxZoomPercent = maxPercentText.get_attribute("value") driver.execute_script("arguments[0].scrollIntoView(true);", maxPercentText) incrementAmount = 40 newMinZoomPercent = Util._changeElementText( self, driver, minPercentText, str(float(minZoomPercent) + incrementAmount)) newMaxZoomPercent = Util._changeElementText( self, driver, maxPercentText, str(float(maxZoomPercent) - incrementAmount)) time.sleep(timeout) # Get the new min and max zoom values. newMinZoomValue = self._getTextValue(driver, "histogramZoomMinValue") newMaxZoomValue = self._getTextValue(driver, "histogramZoomMaxValue") # Check that the new min is larger than the old min print "oldMin=", minZoomValue, " newMin=", newMinZoomValue self.assertGreater(float(newMinZoomValue), float(minZoomValue), "Min did not increase") # Check that the new max is smaller than the old max print "oldMax=", maxZoomValue, " newMax=", newMaxZoomValue self.assertGreater(float(maxZoomValue), float(newMaxZoomValue), "Max did not decrease")
def _getLastValue(self, driver, animator): timeout = selectBrowser._getSleep() lastValueButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.ID, animator + "TapeDeckLastValue"))) driver.execute_script("arguments[0].scrollIntoView(true);", lastValueButton) ActionChains(driver).click(lastValueButton).perform() time.sleep(2)
def test_toolbar_hide(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) time.sleep( timeout ) # Find the preferences button on the menu bar and click it. menuBar = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Menu.MenuBar']"))) preferencesButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Preferences']/.."))) ActionChains(driver).click(preferencesButton).perform() # Click the show button on the sub menu. showButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div/div[text()='Show']/.."))) ActionChains(driver).click( showButton).perform() showToolButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Show Tool Bar']/.."))) ActionChains(driver).click( showToolButton).perform() time.sleep( timeout ) # Verify the toolbar is NOT visible toolVisible = self._isToolbarVisible( driver ) self.assertFalse( toolVisible, "Tool bar was not hidden") # Save the preferences self._savePreferences( driver ) # Show the toolbar # Find the preferences button on the menu bar and click it. preferencesButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Preferences']/.."))) ActionChains(driver).click(preferencesButton).perform() # Click the show tool bar button on the sub menu. ActionChains(driver).send_keys( Keys.ARROW_DOWN ).send_keys( Keys.ARROW_RIGHT ).send_keys( Keys.ARROW_DOWN ).send_keys( Keys.ARROW_DOWN ).send_keys( Keys.ENTER ).perform() time.sleep( timeout ) #Verify the toolbar is now visible toolBar = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Menu.ToolBar']"))) # Click the restore sessions button self._clickSessionButton( driver ) self._clickSessionRestoreButton( driver ) # Select tSnapshotPreferences in the restore combo box self._selectRestoreSnapshot( driver, "tSnapshotPreferences") # Hit the restore button self._restoreSnapshot( driver ) # Close the restore dialog self._closeRestore( driver ) time.sleep( timeout ) # Verify the toolbar is hidden again toolVisible = self._isToolbarVisible( driver) self.assertFalse( toolVisible, "Tool bar was not hidden with restore state")
def _chooseNewColorMap(self, driver): timeout = selectBrowser._getSleep() colorMapCombo = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "colorMapName"))) driver.execute_script("arguments[0].scrollIntoView(true);", colorMapCombo) ActionChains(driver).click(colorMapCombo).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ENTER).perform() time.sleep(timeout)
def test_groupUngroup(self): driver = self.driver timeout = selectBrowser._getSleep() #Load images Util.load_image(self, driver, "Orion.methanol.cbc.contsub.image.fits") Util.load_image(self, driver, "Orion.cont.image.fits") Util.load_image(self, driver, "TWHydra_CO2_1line.image.fits") time.sleep(2) #Open the image settings #Open the stack tab Util.openSettings(self, driver, "Image", True) Util.clickTab(driver, "Stack") #Turn off auto select autoSelectCheck = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "autoSelectImages"))) ActionChains(driver).click(autoSelectCheck).perform() #Select all images (The third should already be selected so selecting #the first with a shift should do it). firstItem = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='skel.widgets.Image.Stack.TreeItem']/div[text()='Orion.methanol.cbc.contsub.image.fits']/.." ))) actions = ActionChains(driver).key_down(Keys.SHIFT).click(firstItem) actions.key_up(Keys.SHIFT).perform() #Click the group check box. groupCheck = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "stackGroupImages"))) ActionChains(driver).click(groupCheck).perform() time.sleep(2) #Verify that the images now have RGB boxes. self._verifyRGB(driver, "Orion.methanol.cbc.contsub.image.fits", "rgba(255, 0, 0, 1)") self._verifyRGB(driver, "Orion.cont.image.fits", "rgba(0, 255, 0, 1)") self._verifyRGB(driver, "TWHydra_CO2_1line.image.fits", "rgba(0, 0, 255, 1)") #Ungroup the images. groupCheck = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "stackGroupImages"))) ActionChains(driver).click(groupCheck).perform() time.sleep(2) #Verify the images have transparent RGB boxes. self._verifyRGB(driver, "Orion.methanol.cbc.contsub.image.fits", "rgba(0, 0, 0, 0)") self._verifyRGB(driver, "Orion.cont.image.fits", "rgba(0, 0, 0, 0)") self._verifyRGB(driver, "TWHydra_CO2_1line.image.fits", "rgba(0, 0, 0, 0)")
def test_imageAnimatorBoundaryAnimation(self): driver = self.driver timeout = selectBrowser._getSleep() # Open a test image so we have something to animate Util.load_image(self, driver, "aH.fits") Util.load_image(self, driver, "aJ.fits") Util.load_image(self, driver, "TWHydra_CO2_1line.image.fits") Util.load_image(self, driver, "Default") time.sleep(timeout) # Record the first image value self._getFirstValue(driver, "Image") # Record the last image value self._getLastValue(driver, "Image") lastImageValue = self._getCurrentValue(driver, "Image") # Find and click the lower spin box lowerBoundText = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@id='ImageLowerBoundSpin']/input"))) driver.execute_script("arguments[0].scrollIntoView(true);", lowerBoundText) lowerBoundText.click() # Change the lower bound value imageLowerBoundValue = Util._changeElementText(self, driver, lowerBoundText, 1) # Find and click the upper spin box imageUpperBoundText = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@id='ImageUpperBoundSpin']/input"))) driver.execute_script("arguments[0].scrollIntoView(true);", imageUpperBoundText) imageUpperBoundText.click() # Change the upper bound value imageUpperBoundValue = Util._changeElementText(self, driver, imageUpperBoundText, int(lastImageValue) - 1) # Allow animation for 2 seconds self._animateForward(driver, "Image") time.sleep(2) # Check that the lower and upper bound values did not change during animation lowerBound = lowerBoundText.get_attribute("value") upperBound = imageUpperBoundText.get_attribute("value") self.assertEqual(int(lowerBound), int(imageLowerBoundValue), "Lower bound image value changed during animation") self.assertEqual(int(upperBound), int(imageUpperBoundValue), "Upper bound image value changed during animation")
def test_remove(self): driver = self.driver timeout = selectBrowser._getSleep() # Wait for the image window to be present (ensures browser is fully loaded) imageWindow = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Find and select the colormap window. colorWindow = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowColormap']" ))) self.assertIsNotNone(colorWindow, "Could not find color map window") ActionChains(driver).click(colorWindow).perform() # For later use, determine the number of DisplayWindows. windowCount = Util.get_window_count(self, driver) print "Window Count=", windowCount # Click the Window button windowButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='qx.ui.toolbar.MenuButton']/div[text()='Window']/.." ))) self.assertIsNotNone( windowButton, "Could not find window button in the context menu") ActionChains(driver).click(windowButton).perform() # Look for the remove button in the submenu. removeButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Remove']/.."))) self.assertIsNotNone( removeButton, "Could not find remove button on window subcontext menu.") ActionChains(driver).click(removeButton).perform() time.sleep(timeout) # Verify that there is one less window than was there originally and the colormap window is not in the list. newWindowCount = Util.get_window_count(self, driver) print "New Window Count=", newWindowCount self.assertEqual(windowCount, newWindowCount + 1, "Window was not removed") try: colorWindow = driver.find_element_by_xpath( "//div[@qxclass='skel.widgets.Window.DisplayWindowColormap']") self.assertTrue(False, "Colormap window should be removed") except Exception: print "Colormap window was successfully removed"
def test_deleteContourSet(self): driver = self.driver timeout = selectBrowser._getSleep() #Load a default image Util.load_image( self, driver, "aH.fits") #Show the image settings Util.openImageSettings( self, driver ) # Navigate to Contour tab of the Histogram Settings self._clickContourTab( driver ) # Change the method used to generate the contour set to minimum. generateButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "contourGenerateMethod"))) driver.execute_script( "arguments[0].scrollIntoView(true);", generateButton) ActionChains(driver).click( generateButton ).perform() ActionChains(driver).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Set a minimum contour level of -0.1 self._typeText( driver, "imageContourLevelMin", -0.1 ) # Use 2 levels self._setLevelCount( driver, 2) # Set the spacing to 2 self._typeText(driver, "contourSpacingInterval", 1) # Hit the Add/Update ContourSet button self._clickAddContourSetButton( driver ) # Check that there is now a Tab called Default under Contour Sets self._clickDefaultContourSetTab( driver ) # Check that we have levels -0.1 and 0.9 levels = self._getLevels( driver, "contourLevelListDefault" ) # Check that the levels are correct self.assertEqual( len(levels), 2, "Two contour levels were not generated") self.assertEqual( levels[0], str(-0.1), "First contour was not -0.1") self.assertEqual( levels[1], str(0.9), "Second contour was not 0.9") # Change back to the generator tab self._clickGenerateContourSetTab( driver ) # Now delete the contour set. self._clickDeleteContourSetButton( driver ) # Verify the default contour set is no longer there. try: defaultSetTab = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='qx.ui.tabview.TabButton']/div[contains(text(),'Default')]/.."))) self.assertTrue( False, "Should not be able to find default contour set tab.") except Exception: print "Test succeeded because we should not be able to find a default contour set tab"
def test_tabularAxisCube(self): driver = self.driver timeout = selectBrowser._getSleep() #Load an image with a tabular axis Util.load_image( self, driver, "18h03m_tabular_axis.image") #Verify that there is a Tabular Animator present and # NOT any other animators animWindow = self._getAnimationWindow( driver ) Util.verifyAnimationCount( self, animWindow, 1 ) animatorType = self._getAnimatorType( driver,"TabularAnimatorType" )