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


Python BuiltIn._element_find方法代码示例

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


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

示例1: capture_and_mask_page_screenshot

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
  def capture_and_mask_page_screenshot(self, filename, locators=None,
                                       rects=None):
    '''
    Captures page screenshot and masks specified element.
    '''
    s2l = BuiltIn().get_library_instance('Selenium2Library')
    # note: filename is required because otherwise we don't have reference to 
    #       auto-generated filename
    s2l.capture_page_screenshot(filename)

    rectangles = []

    for locator in locators or []:
      element = s2l._element_find(locator, True, False)
      if element is None:
        raise AssertionError("Could not locate element for '%s'" % (locator))
      x, y = element.location['x'], element.location['y']
      w, h = element.size['width'], element.size['height']
      rectangles.append([x, y, x+w, y+h])

    for rect in rects or []:
      try:
        x, y, w, h = [int(i) for i in rect.split(',')]
        rectangles.append([x, y, x+w, y+h])
      except:
        raise AssertionError("Could not locate rectangle for '%s'" % (rect))

    self.mask_image(filename, rectangles)
开发者ID:canaryhealth,项目名称:RobotS2LScreenshot,代码行数:30,代码来源:__init__.py

示例2: press_control_and_key

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
 def press_control_and_key(self,locator,key):
     """Presses the control Key and Specified key 'key' at element located by the 'locator' """
     selenium = BuiltIn().get_library_instance('Selenium2Library')
     loc = selenium._element_find(locator,True,True)
     loc.send_keys(Keys.CONTROL, 'a')
     time.sleep(1)
     loc.send_keys(Keys.CONTROL,key)
     time.sleep(1)
开发者ID:Tenxlabsmm,项目名称:Demo,代码行数:10,代码来源:CommonLibrary.py

示例3: Highlight_Elements_With_Text_On_Time

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
def Highlight_Elements_With_Text_On_Time(text, time=2):
    from time import sleep
    seleniumlib = BuiltIn().get_library_instance('Selenium2Library')
    locator = u"xpath=//*[contains(text(), {})]".format(utils.escape_xpath_value(text))
    elements = seleniumlib._element_find(locator, False, False)
    for element in elements:
        seleniumlib._current_browser().execute_script("arguments[0].style['outline'] = '3px dotted red';", element)
    sleep(time)
    for element in elements:
        seleniumlib._current_browser().execute_script("arguments[0].style['outline'] = '';", element)
开发者ID:Leits,项目名称:openprocurement.auction,代码行数:12,代码来源:service_keywords.py

示例4: App_Get_Element_Text

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
def App_Get_Element_Text(locator):

		"""

        Retrive the given element text
        """
		logger.info("Retrive the element text")															## This info goes to the Log file
		seleniumlib = BuiltIn().get_library_instance('Selenium2Library')								## Creates an Instance of Selenium2Library
		element = seleniumlib._element_find(locator, True, True)										## Gets the Element by locator and stores into a variable 
		return  element.text																			## Returns the element text
开发者ID:dimagi,项目名称:cloudcare-tests,代码行数:12,代码来源:application_utilities.py

示例5: select_iframe

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
    def select_iframe(self, locator):
        """Sets iframe identified by `locator` as current frame.

        Key attributes for frames are `id` and `name.` See `introduction` for
        details about locating elements.
        """
        selenium2lib = BuiltIn().get_library_instance('Selenium2Library')
        selenium2lib._info("Selecting iframe '%s'." % locator)
        element = selenium2lib._element_find(locator, True, True, tag='iframe')
        selenium2lib._current_browser().switch_to_frame(element)
开发者ID:FonPhannida,项目名称:robotx,代码行数:12,代码来源:_pagetests.py

示例6: _get_element_index

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
 def _get_element_index(self,locator,expected):
     """Returns index of the element at which the 'expected' value found """
     selenium = BuiltIn().get_library_instance('Selenium2Library')
     elements = selenium.get_matching_xpath_count(locator)
     for ele in range(int(elements)):
         newelements = selenium._element_find(locator,False,False)
         actual = newelements[ele].text
         if expected in actual:
             print "header:"+str(newelements[ele].text)
             print 'matched at'+str(ele+1)
             return ele+1
     else:
         return 0
开发者ID:Tenxlabsmm,项目名称:Demo,代码行数:15,代码来源:CommonLibrary.py

示例7: capture_and_crop_page_screenshot

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
  def capture_and_crop_page_screenshot(self, filename, locator=None):
    '''
    Captures page screenshot and crops to specified element.
    '''
    s2l = BuiltIn().get_library_instance('Selenium2Library')
    # note: filename is required because otherwise we don't have reference to 
    #       auto-generated filename
    s2l.capture_page_screenshot(filename)

    element = s2l._element_find(locator, True, False)
    if element is None:
      raise AssertionError("Could not locate element for '%s'" % (locator))
    x, y = element.location['x'], element.location['y']
    w, h = element.size['width'], element.size['height']

    self.crop_image(filename, [x, y, x+w, y+h])
开发者ID:canaryhealth,项目名称:RobotS2LScreenshot,代码行数:18,代码来源:__init__.py

示例8: click_element_using_javascript

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
 def click_element_using_javascript(self, locator, n=1):
     selenium = BuiltIn().get_library_instance("Selenium2Library")
     n = int(n)
     try:
         elements = selenium._element_find(locator, False, True)
         # selenium.execute_javascript("document.getElementById('submit').click();")
         cnt = len(elements)
         print "elements"
         print elements
         print "cnt:" + str(cnt)
         selenium._current_browser().execute_script("arguments[0].click();", elements[n - 1])
         print "Click Done"
         return True
     except Exception as exp:
         print "Got exception in read_multiple_testdata keyword.Error: " + str(exp)
         return False
开发者ID:cptestingqa,项目名称:SampleRepo,代码行数:18,代码来源:CommonLibrary.py

示例9: get_table_values

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
    def get_table_values(self, table_locator):
        selenium2lib = BuiltIn().get_library_instance('Selenium2Library')

        # self._table_element_finder = TableElementFinder()
        dict = {}
        key = None
        # table = selenium2lib._table_element_finder.find(selenium2lib._current_browser, table_locator)
        table = selenium2lib._element_find(table_locator, True, True)
        if table is not None:
            rows = table.find_elements_by_xpath("./tbody/tr")
            # BuiltIn().log("######rows"+str(len(rows)))
            # return rows
            if len(rows) > 0:
                for row in rows:
                    columns = row.find_elements_by_tag_name('td')
                    # BuiltIn().log('##### NO fdf row have '+str(len(columns))+' cell')
                    # return columns[1].text
                    if len(columns) > 0:
                        for i in range(len(columns)):
                            # return range(len(columns)-1)
                            # BuiltIn().log('##########No '+str(i)+' for ')
                            if (i + 1) % 2 == 1:
                                try:
                                    key = columns[i].find_elements_by_tag_name('label')[0].text
                                except Exception, ex:
                                    key = ''
                                if len(key) == 0:
                                    # BuiltIn().log('########## key is null ##########')
                                    break
                                key = key[0:len(key) - 1]
                                # BuiltIn().log('##########key = '+key+'  ')
                            else:
                                dict[key] = columns[i].text
                                # BuiltIn().log('##########value = '+columns[i].text+'  ')

            return dict
开发者ID:xiaoyaojjian,项目名称:RobotframeworkAuto-for-yunfang,代码行数:38,代码来源:RobotExt.py

示例10: Clear_Highlight_Element

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
def Clear_Highlight_Element(locator):
    seleniumlib = BuiltIn().get_library_instance('Selenium2Library')
    element = seleniumlib._element_find(locator, True, True)
    seleniumlib._current_browser().execute_script("arguments[0].style['outline'] = '';", element)
开发者ID:Leits,项目名称:openprocurement.auction,代码行数:6,代码来源:service_keywords.py

示例11: type_keys_into_textbox

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
 def type_keys_into_textbox(self, text_locator,value):
     """Enters text 'value' into 'text_locator' after checking the presence of the locator"""
     selenium = BuiltIn().get_library_instance('Selenium2Library')
     selenium._element_find(text_locator,True,True).send_keys(value)
开发者ID:Tenxlabsmm,项目名称:Demo,代码行数:6,代码来源:CommonLibrary.py

示例12: press_end_key

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
 def press_end_key(self,locator):
     """Presses the End Key starting from the 'locator' """
     selenium = BuiltIn().get_library_instance('Selenium2Library')
     selenium._element_find(locator,True,True).send_keys(Keys.END)
开发者ID:Tenxlabsmm,项目名称:Demo,代码行数:6,代码来源:CommonLibrary.py

示例13: press_page_down_key

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
 def press_page_down_key(self,locator):
     """Presses the page down Key starting from the 'locator' """
     selenium = BuiltIn().get_library_instance('Selenium2Library')
     selenium._element_find(locator,True,True).send_keys(Keys.PAGE_DOWN)
开发者ID:Tenxlabsmm,项目名称:Demo,代码行数:6,代码来源:CommonLibrary.py

示例14: press_up_key

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
 def press_up_key(self,locator):
     """Presses the Up Key at element located by the 'locator' """
     selenium = BuiltIn().get_library_instance('Selenium2Library')
     selenium._element_find(locator,True,True).send_keys(Keys.ARROW_UP)
开发者ID:Tenxlabsmm,项目名称:Demo,代码行数:6,代码来源:CommonLibrary.py

示例15: press_page_up_key

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import _element_find [as 别名]
 def press_page_up_key(self, locator):
     """Presses the page up Key starting from the 'locator' """
     selenium = BuiltIn().get_library_instance("Selenium2Library")
     selenium._element_find(locator, True, True).send_keys(Keys.PAGE_UP)
开发者ID:Tenxlabsmm,项目名称:Demo,代码行数:6,代码来源:CommonLibrary.py


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