def test_histogramLinkRemoval(self): driver = self.driver browser = selectBrowser._getBrowser() # 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 the Histogram window histWindow = self._getHistogramWindow( driver ) ActionChains(driver).click(histWindow).perform() # Open Link settings for the Histogram window 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() # Remove link from the Histogram to the main image window Util.remove_main_link( self, driver, imageWindow ) # 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 ) # Check that the histogram values are default values newMaxZoomValue = self._getTextValue( driver, "histogramZoomMaxValue") self.assertEqual( float(newMaxZoomValue), 1, "Histogram is linked to image after link was removed")
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_histogramChangeLinks(self): driver = self.driver browser = selectBrowser._getBrowser() # 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 Histogram window histWindow = self._getHistogramWindow( driver ) ActionChains(driver).click( histWindow ).perform() # Click the settings button to expose the settings self._openHistogramSettings( driver ) # Open Link settings for the Histogram window 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() # Remove the link from the Histogram to the main image window Util.remove_main_link( self, driver, imageWindow ) # Load an image in a separate window imageWindow2 = Util.load_image_different_window( self, driver, "aH.fits") # Open link settings for the Histogram ActionChains(driver).click( histWindow ).perform() 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() # Link the Histogram to the second image Util.link_second_image( self, driver, imageWindow2) # Check that the histogram values are not default values newMaxZoomValue = self._getTextValue( driver, "histogramZoomMaxValue") self.assertNotEqual( float(newMaxZoomValue), 1, "Histogram did not update to newly linked image")
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_histogramChangeLinks(self): driver = self.driver browser = selectBrowser._getBrowser() # This test only works for Chrome at the moment if browser == 2: # 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 in a separate window imageWindow2 = Util.load_image_different_window(self, driver, "aH.fits") # 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, histWindow) # Open Link settings for the Histogram window ActionChains(driver).context_click(histWindow).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN ).send_keys(Keys.ENTER).perform() # Remove the link from the Histogram to the main image window imageWindow = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']")) ) ActionChains(driver).move_to_element(imageWindow).context_click(imageWindow).send_keys( Keys.ARROW_DOWN ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() time.sleep(timeout) # Exit links before continuing ActionChains(driver).move_to_element(imageWindow).context_click(imageWindow).send_keys( Keys.ARROW_DOWN ).send_keys(Keys.ENTER).perform() # Open link settings for the Histogram ActionChains(driver).context_click(histWindow).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN ).send_keys(Keys.ENTER).perform() # Link the Histogram to the second image ActionChains(driver).move_to_element(histWindow).click(histWindow).drag_and_drop( histWindow, imageWindow2 ).perform() time.sleep(timeout) # Exit links before continuing ActionChains(driver).move_to_element(imageWindow).context_click(imageWindow).send_keys( Keys.ARROW_DOWN ).send_keys(Keys.ENTER).perform() # Check that the histogram values are not default values newMaxZoomValue = self._getTextValue(driver, "histogramZoomMaxValue") self.assertNotEqual(float(newMaxZoomValue), 1, "Histogram did not update to newly linked image")
def test_animatorChangeLink(self): driver = self.driver browser = selectBrowser._getBrowser() timeout = 2*selectBrowser._getSleep() #Load an image with more than one channel so the channel #animator will appear imageWindow = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) Util.load_image( self, driver, "Default") # Enable 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() # Remove Animator link to the image window 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 an image in a different window imageWindow2 = Util.load_image_different_window( self, driver, "Orion.methanol.cbc.contsub.image.fits") # Change link to second image animWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "ChannelAnimatorUpperBound"))) ActionChains(driver).double_click( animWindow ).perform() 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.link_second_image( self, driver, imageWindow2) # 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 to the second image upperBound = upperBoundText.get_attribute("value") self.assertNotEqual( int(upperBound), 0, "Channel animator did not update to second image values") # Show the image animator by loading a second image in the second window 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") print "Animator image count ", imageCount # Check that the Image Animator updates self.assertEqual( int(imageCount), 1, "Image Animator did not update after image was linked")
def test_histogramChangeLinks(self): driver = self.driver browser = selectBrowser._getBrowser() # 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 Histogram window histWindow = self._getHistogramWindow(driver) ActionChains(driver).click(histWindow).perform() # Click the settings button to expose the settings self._openHistogramSettings(driver) # Open Link settings for the Histogram window 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() # Remove the link from the Histogram to the main image window Util.remove_main_link(self, driver, imageWindow) time.sleep(2) # Load an image in a separate window imageWindow2 = Util.load_image_different_window( self, driver, "aH.fits") time.sleep(2) # Open link settings for the Histogram ActionChains(driver).click(histWindow).perform() 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() # Link the Histogram to the second image Util.link_second_image(self, driver, imageWindow2) # Check that the histogram values are not default values newMaxZoomValue = Util._getTextValue(self, driver, "histogramZoomMaxValue") self.assertNotEqual(float(newMaxZoomValue), 1, "Histogram did not update to newly linked image")
def test_animatorChangeLink(self): driver = self.driver browser = selectBrowser._getBrowser() # This test does not work on Firefox if browser == 2: # Load image in a separate window imageWindow2 = Util.load_image_different_window( self, driver, "N15693D.fits") # Click on the Animator to enable it animWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.boundWidgets.Animator']"))) self.assertIsNotNone( animWindow, "Could not find Animator window") ActionChains(driver).click( animWindow ).perform() # 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 Animator link to the main image window ActionChains(driver).context_click( channelText ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Change the link location of the animator to the second image ActionChains(driver).move_to_element( animWindow ).click( animWindow ).drag_and_drop(animWindow, imageWindow2).perform() # Exit Links ActionChains(driver).move_to_element( animWindow ).context_click( animWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Find and click the upper spin box upperBoundText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@id='ChannelUpperBoundSpin']/input"))) self.assertIsNotNone( upperBoundText, "Could not find upper bound spin box" ) driver.execute_script( "arguments[0].scrollIntoView(true);", upperBoundText) # Check that the animator updates to the second image upperBound = upperBoundText.get_attribute("value") self.assertNotEqual( int(upperBound), 0, "Channel animator did not update to second image values") # Show the Image Animator ActionChains(driver).context_click( channelText ).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN).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() # Find and click the upper spin box imageUpperBoundText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@id='ImageUpperBoundSpin']/input"))) self.assertIsNotNone( imageUpperBoundText, "Could not find upper bound for image animator") driver.execute_script( "arguments[0].scrollIntoView(true);", imageUpperBoundText) imageUpperBoundText.click() # Get the image upper spin value imageCount = imageUpperBoundText.get_attribute("value") # Check that the Image Animator updates self.assertEqual( int(imageCount), 0, "Image Animator did not update after image was linked")
def test_animatorRemoveLink(self): driver = self.driver browser = selectBrowser._getBrowser() # This test does not work on Firefox if browser == 2: # Click on the Animator to enable it animWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.boundWidgets.Animator']"))) self.assertIsNotNone( animWindow, "Could not find Animator window") ActionChains(driver).click( animWindow ).perform() # 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() # Navigate to view links from the Animator settings ActionChains(driver).context_click( channelText ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Remove Animator link to the main image window ActionChains(driver).move_to_element( animWindow ).context_click( animWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Exit Links ActionChains(driver).move_to_element( animWindow ).context_click( animWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Load an image Util.load_image(self, driver, "Default") # Find and click the upper spin box upperBoundText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@id='ChannelUpperBoundSpin']/input"))) self.assertIsNotNone( upperBoundText, "Could not find upper bound spin box" ) driver.execute_script( "arguments[0].scrollIntoView(true);", upperBoundText) # Check that the Channel Animator values remained at default values upperBound = upperBoundText.get_attribute("value") self.assertEqual( int(upperBound), -1, "Channel Animator is still linked to image after link was removed") # Show the Image Animator ActionChains(driver).context_click( channelText ).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN).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() # Find and click the upper spin box imageUpperBoundText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@id='ImageUpperBoundSpin']/input"))) self.assertIsNotNone( imageUpperBoundText, "Could not find upper bound for image animator") driver.execute_script( "arguments[0].scrollIntoView(true);", imageUpperBoundText) imageUpperBoundText.click() # Get the image upper spin value imageCount = imageUpperBoundText.get_attribute("value") # Check that the Image Animator is at default values self.assertEqual( int(imageCount), -1, "Image Animator is still linked to image after the link was removed")
def test_menu_hideClipping(self): driver = self.driver browser = selectBrowser._getBrowser() # Click on an CasaImageLoader Window so that clipping is available on the menu. imageWindow = WebDriverWait(driver, 30).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).click(imageWindow).perform() # Verify that clipping commands can be found on the menu bar. menuBar = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Menu.MenuBar']"))) clipping = menuBar.find_elements_by_xpath( "./div[contains(text(), 'Clipping')]") # 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 clippingButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Clipping']/preceding-sibling::div/div"))) styleAtt = clippingButton.get_attribute("style") print "Style", styleAtt if "checked.png" in styleAtt: print "Clipping checked" clipParent = clippingButton.find_element_by_xpath('..') ActionChains(driver).click(clipParent).perform() # Check that the clipping menu item is no longer available try: clipButton = menuBar.find_element_by_xpath( "./div[contains(text(), 'Clipping')]") self.assertTrue(False, "Should not be able to locate clipping button") except Exception: print "Test succeeded because we should not be able to find clipping"
def load_image(unittest, driver, imageName, imageId = "pwUID0"): browser = selectBrowser._getBrowser() timeout = selectBrowser._getSleep() # If image is not specified, load default image # Change this to a test image available where the tests are running # Test image will ideally have more than 3 channels for a successful test run if imageName == "Default": #imageName = "N15693D.fits" #imageName="TWHydra_CO2_1line.image.fits" imageName="Orion.methanol.cbc.contsub.image.fits" # Wait 30 seconds for the imageWindow to appear on the page imageWindow = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Find a window capable of loading an image and select the window ActionChains(driver).double_click( imageWindow ).perform() # Pause, otherwise stale element for Chrome if browser == 2: time.sleep( timeout) # Click the data button dataButton = driver.find_element_by_xpath( "//div[text()='Data']/..") ActionChains(driver).click(dataButton).perform() # Look for the open button and click it to open the file dialog. openDataButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div/div[text()='Open...']/.."))) ActionChains(driver).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Select the specific image loadButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "loadFileButton"))) fileDiv = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[text()='"+imageName+"']"))) driver.execute_script( "arguments[0].scrollIntoView(true);", fileDiv) fileDiv.click() # Click the load button loadButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "loadFileButton"))) loadButton.click() # Now close the file dialog closeButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "closeFileLoadButton"))) closeButton.click() # Check that the window is displaying an image. viewElement = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.boundWidgets.View.View']"))) imageElement = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, imageId))) return imageWindow
def load_image(unittest, driver, imageName, imageId = "pwUID0"): browser = selectBrowser._getBrowser() timeout = selectBrowser._getSleep() # If image is not specified, load default image # Change this to a test image available where the tests are running # Test image will ideally have more than 3 channels for a successful test run if imageName == "Default": #imageName = "N15693D.fits" #imageName="TWHydra_CO2_1line.image.fits" imageName="Orion.methanol.cbc.contsub.image.fits" # Wait 30 seconds for the imageWindow to appear on the page imageWindow = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Find a window capable of loading an image and select the window ActionChains(driver).double_click( imageWindow ).perform() # Pause, otherwise stale element for Chrome time.sleep( timeout) # Click the data button dataButton = driver.find_element_by_xpath( "//div[text()='Data']/..") ActionChains(driver).click(dataButton).perform() # Look for the open button and click it to open the file dialog. openDataButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div/div[text()='Open...']/.."))) ActionChains(driver).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Select the specific image loadButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "loadFileButton"))) fileDiv = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[text()='"+imageName+"']"))) driver.execute_script( "arguments[0].scrollIntoView(true);", fileDiv) fileDiv.click() # Click the load button loadButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "loadFileButton"))) loadButton.click() # Now close the file dialog closeButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "closeFileLoadButton"))) closeButton.click() # Check that the window is displaying an image. viewElement = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.boundWidgets.View.View']"))) imageElement = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, imageId))) return imageWindow
def load_image_different_window(unittest, driver, imageName): timeout = selectBrowser._getSleep() browser = selectBrowser._getBrowser() # Find a window capable of loading an image. 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 ) # Add a new window below the main casa image window emptyWindow = add_window( unittest, driver) # Change the plugin of the empty window to an image loader ActionChains(driver).context_click( emptyWindow ).send_keys(Keys.ARROW_DOWN ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() # Ensure that there is a new image window imageWindow2 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.ID, "CasaImageLoader2"))) ActionChains(driver).double_click( imageWindow2 ).perform() # Click the data button dataButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Data']/.."))) ActionChains(driver).click(dataButton).perform() # Look for the open button and click it to open the file dialog. openDataButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div/div[text()='Open...']/.."))) ActionChains(driver).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Select the specific image loadButton = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "loadFileButton"))) fileDiv = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[text()='"+imageName+"']"))) driver.execute_script( "arguments[0].scrollIntoView(true);", fileDiv) fileDiv.click() # Click the load button loadButton = driver.find_element_by_id( "loadFileButton") loadButton.click() # Now close the file dialog closeButton = driver.find_element_by_id( "closeFileLoadButton") closeButton.click() # Check that the window is displaying an image. viewElement = driver.find_element_by_xpath("//div[@qxclass='skel.boundWidgets.View.View']") imageElement = driver.find_element_by_id("pwUID0") # Return the second image loader window for further linking tests return imageWindow2
def test_animatorChangeLink(self): driver = self.driver browser = selectBrowser._getBrowser() timeout = selectBrowser._getSleep() imageWindow = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Enable the animation window 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 Animator link to the image window 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 an image in a different window imageWindow2 = Util.load_image_different_window( self, driver, "N15693D.fits") # Change link to second image ActionChains(driver).click( channelText ).perform() 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.link_second_image( self, driver, imageWindow2) # 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 to the second image upperBound = upperBoundText.get_attribute("value") self.assertNotEqual( int(upperBound), 0, "Channel animator did not update to second image values") # 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") # Check that the Image Animator updates self.assertEqual( int(imageCount), 0, "Image Animator did not update after image was linked")
def load_image_different_window(unittest, driver, imageName): timeout = selectBrowser._getSleep() browser = selectBrowser._getBrowser() # Find a window capable of loading an image. 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 ) # Add a new window below the main casa image window emptyWindow = add_window( unittest, driver) # Change the plugin of the empty window to an image loader ActionChains(driver).context_click( emptyWindow ).send_keys(Keys.ARROW_DOWN ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() return load_image_windowIndex( unittest, driver,imageName, 2 )
def test_statsChangeLinkUpdate(self): driver = self.driver browser = selectBrowser._getBrowser() # Test only works on Chrome if browser ==2: # Load an image in a new image window imageWindow2 = Util.load_image_different_window( self, driver, "aH.fits") # Find and click on the Statistics window statsWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@id='Statistics']"))) self.assertIsNotNone( statsWindow, "Could not find statistics window") ActionChains(driver).click( statsWindow ).perform() # In Stastics context menu, open Link Settings ActionChains(driver).context_click( statsWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Remove the link from the Statistics Window to the image window imageWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).move_to_element( imageWindow ).context_click( imageWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Change the link to the loaded image ActionChains(driver).move_to_element( statsWindow ).click( statsWindow ).drag_and_drop( statsWindow, imageWindow2).perform() # Exit links ActionChains(driver).move_to_element( statsWindow ).context_click( statsWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Move to the center of the image window so data appears in the Stats Window ActionChains(driver).move_to_element( imageWindow2 ).perform() # Sometimes text does not appear, therefore move mouse cursor ActionChains(driver).move_by_offset( 100, 100 ).perform() # First check that there is text in the Stats Window statsText = len(driver.find_elements_by_xpath("//div[@qxclass='skel.boundWidgets.Label']")) self.assertEqual( int(statsText), 1, "Should be able to find text in Stats Window") # Check that the Stastics window is linked to the image window statsText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.boundWidgets.Label']"))) statsText = statsText.get_attribute('textContent') # Check that the Default sky text appears in the Stats Window statsText = statsText.startswith("Default sky") self.assertEqual( statsText, 1, "Stats window did not link to image after previous link was removed and new link was created to different window")
def test_animatorRemoveLink(self): driver = self.driver browser = selectBrowser._getBrowser() timeout = 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']"))) # 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 an image Util.load_image(self, driver, "Default") # 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 Channel Animator values remained at default values upperBound = upperBoundText.get_attribute("value") self.assertEqual( int(upperBound), 0, "Channel Animator is still linked to image after link was removed") # 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") # Check that the Image Animator is at default values self.assertEqual( int(imageCount), 0, "Image Animator is still linked to image after the link was removed")
def test_animatorAddLink(self): driver = self.driver timeout = selectBrowser._getSleep() browser = selectBrowser._getBrowser() # Load image in a separate window imageWindow2 = Util.load_image_different_window( self, driver, "N15693D.fits") # 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() # 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) # 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") self.assertNotEqual( int(upperBound), 0, "Channel animator did not update to linked image") # 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") # Check that the Image Animator updates self.assertEqual( int(imageCount), 0, "Image Animator did not update after image was linked")
def test_histogramLinkRemoval(self): driver = self.driver browser = selectBrowser._getBrowser() # 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 the Histogram window histWindow = self._getHistogramWindow(driver) ActionChains(driver).click(histWindow).perform() # Open Link settings for the Histogram window 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() # Remove link from the Histogram to the main image window Util.remove_main_link(self, driver, imageWindow) # 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) # Check that the histogram values are default values newMaxZoomValue = Util._getTextValue(self, driver, "histogramZoomMaxValue") self.assertEqual( float(newMaxZoomValue), 1, "Histogram is linked to image after link was removed")
def test_animatorAddLink(self): driver = self.driver timeout = 2*selectBrowser._getSleep() browser = selectBrowser._getBrowser() # 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") # 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_statsRemoveLink(self): driver = self.driver browser = selectBrowser._getBrowser() # This test only works on Chrome if browser == 2: # Find and click on the Statistics window statsWindow = driver.find_element_by_xpath("//div[@id='Statistics']") self.assertIsNotNone( statsWindow, "Could not find statistics window") ActionChains(driver).click( statsWindow ).perform() # In Stastics context menu, open Link Settings ActionChains(driver).context_click( statsWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Remove the link from the Statistics Window to the image window imageWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).move_to_element( imageWindow ).context_click( imageWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Exit links ActionChains(driver).move_to_element( imageWindow ).context_click( imageWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Load a large test image. Util.load_image( self, driver, "aH.fits") # Move to the center of the image window so data appears in the Stats Window imageWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).move_to_element( imageWindow ).perform() # Sometimes text does not appear, therefore move mouse cursor ActionChains(driver).move_by_offset( 100, 100 ).perform() # Check that the Stastics Window is not linked to the image window statsText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.boundWidgets.Label']"))) statsText = statsText.get_attribute('textContent') # Check that the Default sky text appears in the Stats Window statsText = statsText.startswith("Default sky") self.assertEqual( statsText, 0, "Stats window is still linked to the main image window after the link was removed")
def test_histogramLinkRemoval(self): driver = self.driver browser = selectBrowser._getBrowser() # This test only works for Chrome at the moment if browser == 2: # Find the Histogram window histWindow = self._getHistogramWindow(driver) # Open Link settings for the Histogram window ActionChains(driver).context_click(histWindow).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN ).send_keys(Keys.ENTER).perform() imageWindow = driver.find_element_by_xpath("//div[@class='qx-window-pane']") ActionChains(driver).move_to_element(imageWindow).context_click().perform() # Remove link from the main image window from the Histogram ActionChains(driver).move_to_element(imageWindow).context_click().send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_DOWN ).send_keys(Keys.ENTER).perform() # Exit Links before continuing ActionChains(driver).context_click().send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # 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, histWindow) # Check that the histogram values are default values newMaxZoomValue = self._getTextValue(driver, "histogramZoomMaxValue") self.assertEqual(float(newMaxZoomValue), 1, "Histogram is linked to image after link was removed")
def test_menu_hideClipping(self): driver = self.driver browser = selectBrowser._getBrowser() # Click on an CasaImageLoader Window so that clipping is available on the menu. imageWindow = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).click(imageWindow).perform() # Verify that clipping commands can be found on the menu bar. menuBar = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Menu.MenuBar']"))) clipping = menuBar.find_elements_by_xpath( "./div[contains(text(), 'Clipping')]" ) # 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 clippingButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Clipping']/preceding-sibling::div/div"))) styleAtt = clippingButton.get_attribute( "style"); print "Style", styleAtt if "checked.png" in styleAtt: print "Clipping checked" clipParent = clippingButton.find_element_by_xpath( '..') ActionChains(driver).click( clipParent ).perform() # Check that the clipping menu item is no longer available try: clipButton = menuBar.find_element_by_xpath( "./div[contains(text(), 'Clipping')]" ) self.assertTrue( False, "Should not be able to locate clipping button") except Exception: print "Test succeeded because we should not be able to find clipping"
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_animatorRemoveLink(self): driver = self.driver browser = selectBrowser._getBrowser() timeout = 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']"))) # 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 an image Util.load_image(self, driver, "Default") # 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 Channel Animator values remained at default values upperBound = upperBoundText.get_attribute("value") self.assertEqual( int(upperBound), 0, "Channel Animator is still linked to image after link was removed") # 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") # Check that the Image Animator is at default values self.assertEqual( int(imageCount), 0, "Image Animator is still linked to image after the link was removed" )
def test_statsChangeLink(self): driver = self.driver browser = selectBrowser._getBrowser() # This test does not work on Firefox, only Chrome if browser == 2: # Find and click on the image window imageWindow = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) self.assertIsNotNone( imageWindow, "Could not find image display window") ActionChains(driver).click( imageWindow ).perform() # 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 add button in the submenu. addButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div/div[text()='Add']/.."))) self.assertIsNotNone( addButton, "Could not click minimize button on window subcontext menu.") 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']"))) self.assertIsNotNone( emptyWindow, "Could not find empty display window") # Select the empty window ActionChains(driver).click( emptyWindow ).perform() # Change the plugin of the empty window to an image loader ActionChains(driver).context_click( emptyWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() # Find and click on the Statistics window statsWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@id='Statistics']"))) self.assertIsNotNone( statsWindow, "Could not find statistics window") ActionChains(driver).click( statsWindow ).perform() # In Stastics context menu, open Link Settings ActionChains(driver).context_click( statsWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Remove the link from the Statistics Window to the main image window imageWindow = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) ActionChains(driver).move_to_element( imageWindow ).context_click( imageWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Change the link to the new image window imageWindow2 = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@id='CasaImageLoader2']"))) ActionChains(driver).move_to_element( statsWindow ).click( statsWindow ).drag_and_drop( statsWindow, imageWindow2).perform() # Exit links ActionChains(driver).move_to_element( statsWindow ).context_click( statsWindow ).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform() # Load an image in the main image window Util.load_image( self, driver, "aH.fits") # Move to the center of the image window so data appears in the Stats Window ActionChains(driver).move_to_element( imageWindow ).perform() # Sometimes text does not appear, therefore move mouse cursor ActionChains(driver).move_by_offset( 100, 100 ).perform() # Check that the Stastics Window is not linked to the image window statsText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.boundWidgets.Label']"))) statsText = statsText.get_attribute('textContent') # Check that the Default sky text appears in the Stats Window statsText = statsText.startswith("Default sky") self.assertEqual( statsText, 0, "Stats window is still linked to the main image window after the link was removed")
def test_animatorAddLink(self): driver = self.driver timeout = selectBrowser._getSleep() browser = selectBrowser._getBrowser() # Load image in a separate window imageWindow2 = Util.load_image_different_window( self, driver, "N15693D.fits") # 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() # 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) # 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") self.assertNotEqual(int(upperBound), 0, "Channel animator did not update to linked image") # 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") # Check that the Image Animator updates self.assertEqual( int(imageCount), 0, "Image Animator did not update after image was linked")
def test_animatorChangeLink(self): driver = self.driver browser = selectBrowser._getBrowser() timeout = 2 * selectBrowser._getSleep() #Load an image with more than one channel so the channel #animator will appear imageWindow = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) Util.load_image(self, driver, "Default") # Enable 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() # Remove Animator link to the image window 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 an image in a different window imageWindow2 = Util.load_image_different_window( self, driver, "Orion.methanol.cbc.contsub.image.fits") # Change link to second image animWindow = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.ID, "ChannelAnimatorUpperBound"))) ActionChains(driver).double_click(animWindow).perform() 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.link_second_image(self, driver, imageWindow2) # 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 to the second image upperBound = upperBoundText.get_attribute("value") self.assertNotEqual( int(upperBound), 0, "Channel animator did not update to second image values") # Show the image animator by loading a second image in the second window 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") print "Animator image count ", imageCount # Check that the Image Animator updates self.assertEqual( int(imageCount), 1, "Image Animator did not update after image was linked")
def setUp(self): browser = selectBrowser._getBrowser() Util.setUp(self, browser)
def test_animatorChangeLink(self): driver = self.driver browser = selectBrowser._getBrowser() timeout = selectBrowser._getSleep() imageWindow = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Window.DisplayWindowImage']"))) # Enable the animation window 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 Animator link to the image window 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 an image in a different window imageWindow2 = Util.load_image_different_window( self, driver, "N15693D.fits") # Change link to second image ActionChains(driver).click(channelText).perform() 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.link_second_image(self, driver, imageWindow2) # 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 to the second image upperBound = upperBoundText.get_attribute("value") self.assertNotEqual( int(upperBound), 0, "Channel animator did not update to second image values") # 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") # Check that the Image Animator updates self.assertEqual( int(imageCount), 0, "Image Animator did not update after image was linked")
def test_animatorAddRemove(self): driver = self.driver browser = selectBrowser._getBrowser() 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']")) ) # In order to have a channel and image animator available, we need at least two images, # one of which has multiple channels. Util.load_image(self, driver, "Default") Util.load_image(self, driver, "aJ.fits") # Click on Animator window so its actions will be enabled 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 channelText = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "ChannelIndexText"))) ActionChains(driver).click(channelText).perform() # Right click the toolbar to bring up the context menu toolBar = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Menu.ToolBar']")) ) ActionChains(driver).context_click(toolBar).perform() # Click the customize item on the menu customizeButton = WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.XPATH, "//div[text()='Customize...']/..")) ) ActionChains(driver).click(customizeButton).perform() # First make sure animator is checked animateButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, "//div[text()='Animate']/preceding-sibling::div/div")) ) styleAtt = animateButton.get_attribute("style") if not "checked.png" in styleAtt: print "Clicking animate to make buttons visible on tool bar" animateParent = animateButton.find_element_by_xpath("..") driver.execute_script("arguments[0].scrollIntoView(true);", animateParent) ActionChains(driver).click(animateParent).perform() # Verify both the channel and image checkboxes are on the toolbar menuBar = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Menu.MenuBar']")) ) channelCheck = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Channel']/following-sibling::div[@class='qx-checkbox']") ) ) animateCheck = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Image']/following-sibling::div[@class='qx-checkbox']") ) ) # Uncheck both buttons channelChecked = self._isChecked(channelCheck) print "Channel checked", channelChecked if channelChecked: self._click(driver, channelCheck) animateChecked = self._isChecked(animateCheck) print "Animate checked", animateChecked if animateChecked: self._click(driver, animateCheck) time.sleep(timeout) # Verify that the animation window has only a Stokes animator Util.verifyAnimationCount(self, animWindow, 1) # Check the image animate button and verify that the image animator shows up self._click(driver, animateCheck) imageAnimator = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.boundWidgets.Animator']/div/div/div[text()='Image']") ) ) time.sleep(timeout) Util.verifyAnimationCount(self, animWindow, 2) # Check the channel animator button and verify there are now two animators, one channel, one image. self._click(driver, channelCheck) channelAnimator = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.boundWidgets.Animator']/div/div/div[text()='Channel']") ) ) time.sleep(timeout) Util.verifyAnimationCount(self, animWindow, 3) # Chrome gives an error trying to close the page; therefore, refresh the page before # closing the browser. This is required because otherwise memory is not freed. if browser == 2: # Refresh browser driver.refresh() time.sleep(2)
def test_animatorAddRemove(self): driver = self.driver browser = selectBrowser._getBrowser() 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']"))) # Click on Animator window so its actions will be enabled 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 channelText = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "ChannelIndexText"))) ActionChains(driver).click(channelText).perform() # Right click the toolbar to bring up the context menu toolBar = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[@qxclass='skel.widgets.Menu.ToolBar']"))) ActionChains(driver).context_click(toolBar).perform() # Click the customize item on the menu customizeButton = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Customize...']/.."))) ActionChains(driver).click(customizeButton).perform() # First make sure animator is checked animateButton = WebDriverWait(driver, 10).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='Animate']/preceding-sibling::div/div"))) styleAtt = animateButton.get_attribute("style") if not "checked.png" in styleAtt: print "Clicking animate to make buttons visible on tool bar" animateParent = animateButton.find_element_by_xpath('..') driver.execute_script("arguments[0].scrollIntoView(true);", animateParent) ActionChains(driver).click(animateParent).perform() # Verify both the channel and image checkboxes are on the toolbar channelCheck = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[text()='Channel']/following-sibling::div[@class='qx-checkbox']" ))) animateCheck = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[text()='Image']/following-sibling::div[@class='qx-checkbox']" ))) # Uncheck both buttons channelChecked = self._isChecked(channelCheck) print 'Channel checked', channelChecked if channelChecked: self._click(driver, channelCheck) animateChecked = self._isChecked(animateCheck) print 'Animate checked', animateChecked if animateChecked: self._click(driver, animateCheck) time.sleep(timeout) # Verify that the animation window has no animators. self._verifyAnimationCount(animWindow, 0) # Check the image animate button and verify that the image animator shows up self._click(driver, animateCheck) imageAnimator = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='skel.boundWidgets.Animator']/div/div[text()='Image']" ))) time.sleep(timeout) self._verifyAnimationCount(animWindow, 1) # Check the channel animator button and verify there are now two animators, one channel, one image. self._click(driver, channelCheck) channelAnimator = WebDriverWait(driver, 10).until( EC.presence_of_element_located(( By.XPATH, "//div[@qxclass='skel.boundWidgets.Animator']/div/div[text()='Channel']" ))) time.sleep(timeout) self._verifyAnimationCount(animWindow, 2) # Chrome gives an error trying to close the page; therefore, refresh the page before # closing the browser. This is required because otherwise memory is not freed. if browser == 2: # Refresh browser driver.refresh() time.sleep(2)
def load_image_different_window(unittest, driver, imageName): timeout = selectBrowser._getSleep() browser = selectBrowser._getBrowser() # Find a window capable of loading an image. 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) # Add a new window below the main casa image window emptyWindow = add_window(unittest, driver) # Change the plugin of the empty window to an image loader ActionChains(driver).context_click(emptyWindow).send_keys( Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ARROW_RIGHT).send_keys(Keys.ENTER).perform() # Ensure that there is a new image window imageWindow2 = WebDriverWait(driver, 30).until( EC.presence_of_element_located((By.ID, "CasaImageLoader2"))) ActionChains(driver).double_click(imageWindow2).perform() # Click the data button dataButton = WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.XPATH, "//div[text()='Data']/.."))) ActionChains(driver).click(dataButton).perform() # Look for the open button and click it to open the file dialog. openDataButton = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div/div[text()='Open...']/.."))) ActionChains(driver).send_keys(Keys.ARROW_DOWN).send_keys( Keys.ENTER).perform() # Select the specific image loadButton = WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.ID, "loadFileButton"))) fileDiv = WebDriverWait(driver, 20).until( EC.presence_of_element_located( (By.XPATH, "//div[text()='" + imageName + "']"))) driver.execute_script("arguments[0].scrollIntoView(true);", fileDiv) fileDiv.click() # Click the load button loadButton = driver.find_element_by_id("loadFileButton") loadButton.click() # Now close the file dialog closeButton = driver.find_element_by_id("closeFileLoadButton") closeButton.click() # Check that the window is displaying an image. viewElement = driver.find_element_by_xpath( "//div[@qxclass='skel.boundWidgets.View.View']") imageElement = driver.find_element_by_id("pwUID0") # Return the second image loader window for further linking tests return imageWindow2