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


Python BuiltIn.element_text_should_be方法代码示例

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


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

示例1: _BrowserManagementKeywords

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import element_text_should_be [as 别名]

#.........这里部分代码省略.........
                        'passed': suite_status == 'PASS',
                        'tags': tags}
            headers = {'Authorization': 'Basic {0}'.format(token)}
            url = 'https://saucelabs.com/rest/v1/{0}/jobs/{1}'.format(username, self._job_id)
            response = requests.put(url, data=json.dumps(payload), headers=headers)
            assert response.status_code == 200, response.text
            # video_url = json.loads(response.text).get('video_url')
            # if video_url:
                # logger.info('<a href="{0}">video.flv</a>'.format(video_url), html=True)
            ondemand_string = "SauceOnDemandSessionID=%s job-name=%s" % (self._job_id, suite_name)
            print 'setting ONDEMAND_PYRO to : %s' % ondemand_string    
            os.environ['ONDEMAND_PYRO'] = ondemand_string
            #wrapper = Wrapper(self._seleniumlib, username, access_key, sys.argv[2])
            #wrapper.update_sauce_rest(BuiltIn().get_variable_value("${SUITE STATUS}"), BuiltIn().get_variable_value("${TEST_TAGS}"))
        
        self._seleniumlib.close_browser
        self._seleniumlib.close_all_browsers
        print 'CLOSE BROWSER TIME!!'

    def selenium_drag_and_drop(self, locator_type, ele_source, ele_dest):
        self._seleniumlib.drag_and_drop('%s=%s' % (locator_type,ele_source), '%s=%s' % (locator_type,ele_dest))

    def selenium_drag_and_drop_actions(self, locator_type, ele_source, ele_dest):
        self._seleniumlib.mouse_down('%s=%s' % (locator_type,ele_source))
        self._seleniumlib.mouse_over('%s=%s' % (locator_type,ele_dest))
        self._seleniumlib.mouse_up('%s=%s' % (locator_type,ele_dest))

    def selenium_check(self, locator_type, element_locator):
        self._seleniumlib.select_checkbox('%s=%s' % (locator_type,element_locator))
  
    def selenium_uncheck(self, locator_type, element_locator):
        self._seleniumlib.unselect_checkbox('%s=%s' % (locator_type,element_locator))
    
    def selenium_wait_until_element_is_visible(self, locator_type, element_locator, _timeout=5):
        self._seleniumlib.wait_until_element_is_visible('%s=%s' % (locator_type,element_locator), timeout=_timeout)
    
    def selenium_wait_for_element_present(self, locator_type, element_locator):
        self._seleniumlib.wait_until_page_contains_element('%s=%s' % (locator_type,element_locator))
    
    def selenium_verify_text_from_element(self, locator_type, element_locator, text):
        self._seleniumlib.element_text_should_be('%s=%s' % (locator_type,element_locator), text)
    
    def selenium_reload(self, suspend_after_element_found='createUser_wiz'):
        """Refreshes the browser, which is effectively like the user pressed F5.
        Optional, supply the suspend_after_element_found with an element to find after reloading and apply the following javascript:
           window.ADTRAN.store.RefreshBaseStore.suspendAll();
           window.ADTRAN.util.SysPollTask.suspend();
        Note: Setting this to equal None will disable the javascript and wait for element functionality entirely
        """        
        print '(selenium_reload) suspend = %s' % suspend_after_element_found
        self._seleniumlib.reload_page()
        if type(suspend_after_element_found) == type(''):
            print '(selenium_reload) javascript suspendAll issued! (suspend_after_element_found == %s' % suspend_after_element_found
            self._seleniumlib.wait_until_element_is_visible(suspend_after_element_found, error='(selenium_reload) failed because the element was not found after reload')
            self._seleniumlib.execute_javascript('window.ADTRAN.store.RefreshBaseStore.suspendAll();')
            self._seleniumlib.execute_javascript('window.ADTRAN.util.SysPollTask.suspend();')
            
    def selenium_type(self, locator_type, element_locator, text):
        self._seleniumlib.input_text('%s=%s' % (locator_type,element_locator), text)
    
    def selenium_clear(self, locator_type, element_locator):
        self._seleniumlib.input_text('%s=%s' % (locator_type,element_locator), '')
        
    def selenium_verify_attribute_from_element(self, locator_type, element_locator, element_class_locator, text):
        attr_value = self._seleniumlib.get_element_attribute('%s=%[email protected]%s' % (locator_type, element_locator, element_class_locator))
        BuiltIn().should_contain(text, attr_value)
    
    def selenium_click(self, locator_type, element_locator, wait_before_click=5):
        BuiltIn().sleep(wait_before_click)
        self._seleniumlib.click_element('%s=%s' % (locator_type,element_locator))

    def selenium_click_text_from_combobox(self, locator_type, element_locator, text):
        self.selenium_wait_for_element_present(locator_type, element_locator)
        self._seleniumlib.click_element('%s=%s' % (locator_type,element_locator))
        self.selenium_wait_for_element_present('xpath', "//div[contains(@class, 'x-boundlist') and not(contains(@style, 'display: none;'))]/div")
        self.selenium_click('xpath', "//div[contains(@class, 'x-boundlist') and not(contains(@style, 'display: none;'))]/div/ul/li[contains(text(), '%s')]" % text) 

    def selenium_click_text_from_combobox_search(self, locator_type, element_locator, text):
        self.selenium_wait_for_element_present(locator_type, element_locator)        
        self.selenium_type(locator_type, element_locator, text)        
        self.selenium_wait_for_element_present('xpath', "//div[contains(@class, 'x-boundlist') and not(contains(@style, 'display: none;'))]/div")
        self.selenium_click('xpath', "//div[contains(@class, 'x-boundlist') and not(contains(@style, 'display: none;'))]/div/ul/li[contains(text(), '%s')]" % text)
        
    def selenium_populate_combo_and_click_text(self, locator_type, element_locator, text, wait_before_click=5):
        self.selenium_wait_for_element_present(locator_type, element_locator)
        self.selenium_click(locator_type, element_locator)
        #self.selenium_click('xpath', "//div[contains(concat(' ', @class, ' '), 'x-trigger-index-0 x-form-trigger x-form-arrow-trigger x-form-trigger-first')]")
        self.selenium_click('xpath', "//input[@%s='%s']/../../td[2]/div" % (locator_type,element_locator))
        BuiltIn().sleep(wait_before_click)
        #self.selenium_click('xpath', "//li[contains(text(), '%s')]" % text)
        self.selenium_click('xpath', "//div[contains(@class, 'x-boundlist') and not(contains(@style, 'display: none;'))]/div/ul/li[contains(text(), '%s')]" % text) 

    def selenium_double_click(self, locator_type, element_locator):
        self._seleniumlib.double_click_element('%s=%s' % (locator_type, element_locator))
    
    def selenium_element_should_not_be_visible(self, locator_type, element_locator):
        self._seleniumlib.element_should_not_be_visible('%s=%s' % (locator_type, element_locator))
        
    def selenium_click_by_script(self, element_locator):
        self._seleniumlib.execute_javascript("window.document.getElementById('%s').click();" % element_locator)
开发者ID:Tallisado,项目名称:pyrolibrary,代码行数:104,代码来源:_browsermanagement.py

示例2: Inbox

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import element_text_should_be [as 别名]

#.........这里部分代码省略.........
    def open_email_by_subject(self, subject):
        locator = self.elements['mail_table']

        email_table = self._selenium2Library.element_find(locator, True, False, None)
        # Find the checkbox which subject is match with the given subject
        xpath_locator = ".//span[normalize-space(@title)='" + subject + "']"
        _element = email_table.find_element(By.XPATH, xpath_locator)
        _element.click()
        self._selenium2Library.wait_until_page_load(self._selenium2Library.timeout)

    '''
    Usage: Select the email by pre-define category
    Params:
        category: All, None, Read, Unread, Starred, Unstarred
    '''
    def select_email_by_category(self, category):
        self._selenium2Library.click_element(self.elements['btn_popup_category'])
        xpath_locator = "xpath=//div[@id='menu-ml-cbox']//span[text()='" + category + "']"
        self._selenium2Library.wait_until_element_is_visible(xpath_locator,
                                                             self._selenium2Library.timeout)
        button = self._selenium2Library.element_find(xpath_locator, True, False, None)
        button.click()

        '''
    Usage: Select the email by pre-define category
    Params:
        category: All, None, Read, Unread, Starred, Unstarred
    '''

    '''
    Usage: Click to compose an email
    Params:

    '''
    def compose_email(self):
        self._selenium2Library.click_element(self.elements['btn_compose'])
        self._selenium2Library.wait_until_element_is_visible(self.elements['txt_to_field'])

    '''
    Usage: Add recipient
    Params:
        to: list of to recipients, separated by ;
        cc: list of cc recipients, separeted by ;
        bcc: list of bcc recipients, separated by ;
    '''
    def _input_recipient(self, locator, text):
        for item in text.split(";"):
            input_text = item.split("|")
            if len(input_text)==1:
                self._selenium2Library.input_text(locator, input_text, False)
                self._selenium2Library.input_text(locator, Keys.TAB, False)
            else:
                self._selenium2Library.input_text(locator, input_text[0], False)
                text_holder = "xpath=//div[contains(.,'" + input_text[1] +"')]"
                self._selenium2Library.wait_until_element_is_displayed(text_holder, self._selenium2Library.timeout)
                #self._selenium2Library.delay(1)
                self._selenium2Library.click_element(text_holder)

    def add_recipients(self, to=None, cc=None, bcc=None):
        list_fields = [to, cc, bcc]
        list_locators = [self.elements['txt_to_field'], self.elements['txt_cc_field'], self.elements['txt_bcc_field']]
        for i in range(len(list_fields)):
            if list_fields[i]:
                self._input_recipient(list_locators[i], list_fields[i])

    def add_content(self, subject, body, override=True):
        if subject:
            self._selenium2Library.input_text(self.elements['txt_subject_field'], subject, override)
        if body:
            self._selenium2Library.input_text(self.elements['txt_body_field'], body, override)

    '''
    Usage: Click Send button to send email
    Params:
    '''
    def send_email(self):
        self._selenium2Library.click_element(self.elements['btn_send'])

    def verify_email_content(self, from_recipient=None, content=None):
        if from_recipient:
            self._selenium2Library.element_text_should_be(self.elements['lbl_from'], from_recipient.strip())
        if content:
            self._selenium2Library.element_text_should_be(self.elements['txt_mail_content'], content.strip())

    '''
    Usage: Delete the selected email
    '''
    def delete_selected_email(self):
        self._selenium2Library.click_element(self.elements['btn_delete'])

        '''
    Usage: Open email by subject
    '''
    def refresh_page_until_email_by_subject_exist(self, subject, timeout):
        # locator = self.elements['mail_table']
        # email_table = self._selenium2Library.element_find(locator, True, False, None)
        # Find the checkbox which subject is match with the given subject
        logger.info(subject, True, True)
        xpath_property = "xpath=//span[normalize-space(@title)='" + subject + "']"
        self._selenium2Library.reload_page_until_element_displayed(xpath_property, timeout)
开发者ID:vumvo,项目名称:MyFirstGitHub,代码行数:104,代码来源:Inbox.py


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