当前位置: 首页>>代码示例>>Python>>正文


Python WebDriverWait.find_element_by_xpath方法代码示例

本文整理汇总了Python中selenium.webdriver.support.ui.WebDriverWait.find_element_by_xpath方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.find_element_by_xpath方法的具体用法?Python WebDriverWait.find_element_by_xpath怎么用?Python WebDriverWait.find_element_by_xpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.support.ui.WebDriverWait的用法示例。


在下文中一共展示了WebDriverWait.find_element_by_xpath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_unitChange

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
 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")
开发者ID:slovelan,项目名称:NRAODev,代码行数:28,代码来源:tColorMap.py

示例2: log_in

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
 def log_in(self):
     page = 'https://sb.fgv.br/catalogo-rj'
     self.driver.get(page)
     mainframe = self.driver.find_element_by_name("mainFrame")
     self.driver.switch_to.frame(mainframe)
     element = WebDriverWait(self.driver, 10).until(ec.presence_of_element_located((By.ID, "tab_principal")))
     element.find_element_by_xpath('//*[@class="centro"]/span[6]/a').click()
     self.driver.switch_to.frame(self.driver.find_element_by_xpath('//*[@id="div_area_iframe"]/iframe'))
     user_login = WebDriverWait(self.driver, 10).until(ec.presence_of_element_located((By.NAME, 'codigo')))
     user_login.send_keys("")
     password = self.driver.find_element_by_name('senha')
     password.send_keys("")
     self.driver.find_element_by_xpath('//*[@id="button1"]').click()
     time.sleep(5)
     self.driver.find_element_by_xpath('//*[@class="button_login"]').click()
开发者ID:marciomacielbastos,项目名称:dever_de_casa_java,代码行数:17,代码来源:Login.py

示例3: test_profileRegion

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
    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")
开发者ID:slovelan,项目名称:NRAODev,代码行数:35,代码来源:tProfile.py

示例4: export_project

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
 def export_project(self, project_name):
     """ Clicks the 'export' button. Returns :class:`ExportDialog`. """
     self.search_input = project_name
     element = WebDriverWait(self.browser, TMO).until(
                   lambda browser: browser.find_element_by_link_text(project_name))
     element = element.find_element_by_xpath('../../td[6]/form[2]/button')
     element.click()
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:9,代码来源:project.py

示例5: _getColorMapName

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
 def _getColorMapName( self, driver ):
     colorMapCombo = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "colorMapName")))
     driver.execute_script( "arguments[0].scrollIntoView(true);", colorMapCombo )
     colorMapText = colorMapCombo.find_element_by_xpath( ".//div/div")
     mapName = colorMapText.text
     ActionChains(driver).click( colorMapCombo ).perform()
     return mapName
开发者ID:slovelan,项目名称:NRAODev,代码行数:9,代码来源:tColorMap.py

示例6: _setLevelCount

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
    def _setLevelCount(self, driver, value):
        levelSpinParent = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "imageContourLevelCount")))
        #Upper spin button
        levelSpinInput = levelSpinParent.find_element_by_xpath( ".//input" )
        currentValue = levelSpinInput.get_attribute("value")
        print "Current level ", currentValue
        diff = value - int(currentValue)
        print "Diff=",diff
        levelButs = levelSpinParent.find_elements_by_class_name( "qx-button")
        buttonCount = len( levelButs )
        print "Button count=",buttonCount
        buttonIndex = 0

        if diff < 0 :
            #Use the decrease button if both buttons are enabled
            if buttonCount > 1 :
                buttonIndex = 1
            #levelSpinButton = levelSpinParent.find_element_by_xpath( ".//div[1]")
            diff = diff * -1

        ActionChains( driver).move_to_element( levelButs[buttonIndex] )
        for i in range( diff ):
            ActionChains(driver).click( levelButs[buttonIndex] ).perform()
        newValue = levelSpinInput.get_attribute("value")
        self.assertEqual( newValue, str(value), "Level spin not correct")
开发者ID:Astroua,项目名称:CARTAvis,代码行数:27,代码来源:tContour.py

示例7: verifyCompositionMode

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
 def verifyCompositionMode(self, driver, mode):
     print "verifying mode=", mode
     combineCombo = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "layerCompositionMode")))
     driver.execute_script( "arguments[0].scrollIntoView(true);", combineCombo )
     combineText = combineCombo.find_element_by_xpath( ".//div/div")
     combMode = combineText.text
     print "Combine mode=",combMode
     self.assertTrue( mode==combMode, "Combine modes not as expected")
开发者ID:Astroua,项目名称:CARTAvis,代码行数:10,代码来源:tStack.py

示例8: __set_working_hours

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
  def __set_working_hours(self):
    main2_form = WebDriverWait(self.driver, 5).until(EC.presence_of_element_located((By.NAME, 'main2_form')))
    tr = main2_form.find_element_by_xpath('p/table[1]/tbody/tr[2]')
    basic = tr.find_element_by_xpath('td[5]').text
    extra = tr.find_element_by_xpath('td[6]').text

    if basic != '_': self.working_hours_basic[self.half_now] = basic
    if extra != '_': self.working_hours_extra[self.half_now] = extra
开发者ID:bakunyo,项目名称:e-navi2e-staffing,代码行数:10,代码来源:estaffing.py

示例9: edit_project

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
 def edit_project(self, project_name):
     """ Clicks the 'edit' button. Returns :class:`ProjectInfoPage`. """
     self.search_input = project_name
     element = WebDriverWait(self.browser, TMO).until(
                   lambda browser: browser.find_element_by_link_text(project_name))
     element = element.find_element_by_xpath('../../td[6]/form/input')
     element.click()
     title = ProjectInfoPage.project_title(project_name)
     return ProjectInfoPage.verify(self.browser, self.port, title)
开发者ID:Kenneth-T-Moore,项目名称:OpenMDAO-Framework,代码行数:11,代码来源:project.py

示例10: test_binCountChange

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
    def test_binCountChange(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 histogram window 
        histWindow = self._getHistogramWindow( driver )
        ActionChains(driver).double_click( histWindow )
        time.sleep( timeout )

        # Click the settings button to expose the settings
        self._openHistogramSettings( driver )

        # Navigate to Display tab of the Histogram Settings
        displayTab = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='qx.ui.tabview.TabButton']/div[contains(text(),'Display')]/..")))
        driver.execute_script( "arguments[0].scrollIntoView(true);", displayTab)
        ActionChains(driver).click( displayTab ).perform()

        # Look for the binCountText field.
        binCountText = driver.find_element_by_xpath( "//input[starts-with(@id,'histogramBinCountTextField')]" )
        # Scroll the histogram window so the bin count at the bottom is visible.
        driver.execute_script( "arguments[0].scrollIntoView(true);", binCountText)
        textValue = binCountText.get_attribute("value")
        print "value of text field=", textValue
        
        # Calculate percent difference from center.  Note this will fail if the upper
        # bound of the slider changes.
        textScrollPercent = (500 - int(float(textValue))) / 1000.0
        print "scrollPercent=",textScrollPercent
       
        # Look for the bin count slider.
        binCountSlider = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[starts-with(@id, 'histogramBinCountSlider')]")))
        # Width of the slider
        sliderSize = binCountSlider.size
        # Amount we need to move in order to get to the center
        sliderScrollAmount = sliderSize['width'] * textScrollPercent
        print 'Slider scroll=',sliderScrollAmount
        
        # Look for the scroll bar in the slider and get its size
        sliderScroll = binCountSlider.find_element_by_xpath( ".//div")
        self.assertIsNotNone( sliderScroll, "Could not find bin count slider scroll")
        scrollSize = sliderScroll.size
        print 'Scroll width=', scrollSize['width']
        
        # Subtract half the width of the slider scroll.
        sliderScrollAmount = sliderScrollAmount - scrollSize['width'] / 2
        print 'Slider scroll adjusted=',sliderScrollAmount
        ActionChains( driver ).drag_and_drop_by_offset( sliderScroll, sliderScrollAmount, 0 ).perform()
        time.sleep( timeout )

        # Check that the value goes to the server and gets set in the text field.
        newText = binCountText.get_attribute( "value")
        print 'Text=',newText
        self.assertAlmostEqual( int(float(newText)), 5000 ,None,"Failed to scroll halfway",250)
开发者ID:durga2112,项目名称:CARTAvis,代码行数:58,代码来源:tHistogram.py

示例11: delete_project

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
    def delete_project(self, project_name):
        self.search_input = project_name
        element = WebDriverWait(self.browser, TMO).until(
                      lambda browser: browser.find_element_by_link_text(project_name))
        element = element.find_element_by_xpath('../../td[6]/form[1]/button')
        element.click()

        delete_dialog = DeleteDialog(self.browser, self.port, (By.XPATH, "/html/body/div[2]"))
        time.sleep(1)  # Wait for silly fade-in.
        delete_dialog.submit()
        time.sleep(1)  # Wait for silly fade-out.
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:13,代码来源:project.py

示例12: edit_project

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
    def edit_project(self, project_name):
        """ Clicks the 'edit' button. Returns :class:`EditDialog`. """
        self.search_input = project_name
        element = WebDriverWait(self.browser, TMO).until(
                      lambda browser: browser.find_element_by_link_text(project_name))
        element = element.find_element_by_xpath('../../td[6]/a')
        element.click()

        page = EditDialog(self.browser, self.port, (By.ID, "editProjectModal"))
        time.sleep(1)  # Wait for silly fade-in.
        return page
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:13,代码来源:project.py

示例13: test_tool_showHideClip

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
    def test_tool_showHideClip(self):    
        driver = self.driver

        # 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']")))
    
        toolBar = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Menu.ToolBar']")))
        self.assertIsNotNone( toolBar, "Could not find the tool bar")
        actionChains = ActionChains(driver)
        actionChains.context_click(toolBar).perform()
        
        # Click the customize item on the menu
        customizeButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Customize...']/..")))
        self.assertIsNotNone( customizeButton, "Could not find the customize button in context")
        ActionChains(driver).click( customizeButton).perform()
        
        # First make sure no clips are checked
        clippingButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Clipping']/preceding-sibling::div/div")))
        self.assertIsNotNone( clippingButton, "Could not clipping button in customize dialog")
        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 there are no  clip buttons on the toolbar by looking for labels with a %
        self._verifyClips( toolBar, 0 )
        
        # Open the Clipping folder by performing 2 clicks so that the 98% clip button is visible
        # clippingTreeItem = clippingButton.find_element_by_xpath( '../..')
        clippingOpenButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Clipping']/../div[@qxclass='qx.ui.tree.core.FolderOpenButton']")))
        self.assertIsNotNone( clippingOpenButton, "Could not find open folder button for clipping")
        ActionChains( driver ).click( clippingOpenButton ).perform()
        clipOpenButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='Clips']/../div[@qxclass='qx.ui.tree.core.FolderOpenButton']")))
        self.assertIsNotNone( clipOpenButton, "Could not find open folder button for clip")
        driver.execute_script( "arguments[0].scrollIntoView(true);", clipOpenButton)
        ActionChains( driver ).click( clipOpenButton ).perform()
        
        # Now click the 98% clip button on the customize dialog
        clipButton = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='98%']/preceding-sibling::div/div/..")))
        self.assertIsNotNone( clipButton, "Could not find clip button in customize dialog")
        ActionChains(driver).click( clipButton).perform()
        
        # Verify that the 98% clip appears on the tool bar
        clipRadio = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[text()='98%']")))
        self.assertIsNotNone( clipRadio, "Clip radio did not appear on tool bar")
        
        # Remove the 98% clip by unclicking the button on the customize dialog
        ActionChains(driver).click( clipButton).perform()
        
        # Verify the all clips are gone
        self._verifyClips( toolBar, 0 )
开发者ID:pfederl,项目名称:CARTAvis,代码行数:55,代码来源:tMenuToolVisibility.py

示例14: test_menu_hideClipping

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
    def test_menu_hideClipping(self):    
        driver = self.driver

        # Click on an CasaImageLoader Window so that clipping is available on the menu.
        imageWindow = WebDriverWait(driver, 20).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']")))
        self.assertIsNotNone( menuBar, "Could not find the menu bar")
        clipping = menuBar.find_elements_by_xpath( "./div[contains(text(), 'Clipping')]" )
        self.assertIsNotNone( clipping, "Clipping not present on menu bar");

        # Now right click the toolbar
        toolBar = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@qxclass='skel.widgets.Menu.ToolBar']")))
        self.assertIsNotNone( toolBar, "Could not find the tool bar")
        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...']/..")))
        self.assertIsNotNone( customizeButton, "Could not find the customize button in context")
        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")))
        self.assertIsNotNone( clippingButton, "Could not clipping button in customize dialog")
        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"   
开发者ID:pfederl,项目名称:CARTAvis,代码行数:42,代码来源:tMenuToolVisibility.py

示例15: delete_all_test_projects

# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import find_element_by_xpath [as 别名]
    def delete_all_test_projects(self, verbose=False):
        """ Removes all projects with 'test project' in the name.
            Not perfect, will timeout when it runs out of projects"""

        elements = self.browser.find_elements_by_partial_link_text('testing project')
        for i in range(len(elements)):
            element = WebDriverWait(self.browser, TMO).until(
                lambda browser: browser.find_element_by_partial_link_text('testing project'))

            project_name = element.text
            element = element.find_element_by_xpath('../../td[6]/form/input')
            element.click()
            title = ProjectInfoPage.project_title(project_name)
            ProjectInfoPage.verify(self.browser, self.port, title).delete_project()
            if verbose:
                print >>sys.stderr, 'Deleted', project_name
开发者ID:Kenneth-T-Moore,项目名称:OpenMDAO-Framework,代码行数:18,代码来源:project.py


注:本文中的selenium.webdriver.support.ui.WebDriverWait.find_element_by_xpath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。