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


Python BuiltIn.wait_until_element_is_visible方法代码示例

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


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

示例1: wait_for_element_visible

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import wait_until_element_is_visible [as 别名]
 def wait_for_element_visible(self,locator,timeout=None,messgae=''):
         
           if(timeout == None):
               timeout = "30s"
           selenium = BuiltIn().get_library_instance('Selenium2Library')
           for iCounter in range(1,3):
                   selenium.wait_until_page_contains_element(locator,timeout)
                   selenium.wait_until_element_is_visible(locator,timeout)
           return true
开发者ID:Tungalasriharibabu,项目名称:MM1,代码行数:11,代码来源:TableData.py

示例2: table_get_column_no

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import wait_until_element_is_visible [as 别名]
 def table_get_column_no(self, table_locator, columnName):
   """Returns the column number of the column matching 'columnName' from the table located at 'table_locator'."""
   #try:
   selenium = BuiltIn().get_library_instance('Selenium2Library')
   selenium.wait_until_element_is_visible(table_locator,time.sleep(10))
   colCount = int(selenium.get_matching_xpath_count(table_locator+'/div[contains(@class,"dgrid-header dgrid-header-row")]/table[contains(@id,"-header")]/tr/th'))
   print "colCount:"+str(colCount)
   for iCounter in range(1,colCount+1):
       curColName = selenium._get_text(table_locator+'//div[contains(@class,"dgrid-header dgrid-header-row")]/table[contains(@id,"-header")]/tr/th['+str(iCounter)+']')
       if (curColName.replace(' ','').strip().lower()==columnName.replace(' ','').strip().lower()):
           print "column name matched at "+str(iCounter)
           return iCounter
   return 0
开发者ID:Tungalasriharibabu,项目名称:MM1,代码行数:15,代码来源:TableData.py

示例3: DrupalKeywords

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

#.........这里部分代码省略.........
        - `cancel_policy`: What do we do precisely with the user account and his content
        | `cancel_policy=user_cancel_block` | Disable the account and keep its content. *(default)* |
        | `cancel_policy=user_cancel_block_unpublish` |  Disable the account and unpublish its content. |
        | `cancel_policy=user_cancel_reassign` | Delete the account and make its content belong to the Anonymous user. |
        | `cancel_policy=user_cancel_delete |  Delete the account and its content. |

        - `exit_on_failure`: Please read the `introduction` about this parameter

        Examples:
        | Comment | Remove member "foobar" as well as his content |
        | Remove Member | foobar |
        | Comment | Remove member "janedoe" but her content is kept and owned by "anonymous user" |
        | Remove Member | janedoe | policy=user_cancel_delete |

        *Warning*: your actual authentication *must* grant user adding, otherwise the keyword fails.
        """
        sel = self.selenium

        # Going to the people mgmt page
        sel.go_to(urljoin(self.home_url, 'admin/people'))

        # Checking we are granted for this
        with FailureManager(exit_on_failure, "You are not allowed to manage members"):
            links = sel.get_all_links()
            assert u'toolbar-link-admin-people' in links

        # Let's find the usename selection widget
        html = self._actual_html()
        users_table = html.xpath('//table[contains(@class, "sticky-enabled")]')
        with FailureManager(exit_on_failure, "It seems there are no members"):
            assert len(users_table) == 1

        # Let' search for our user index
        users_table = users_table[0]
        users_cbx = users_table.xpath('//tr/td[1]//input/@id')  # checkboxes
        users_tds = users_table.xpath('//tr/td[2]/a/text()')  # names
        for checkbox_id, found_username in zip(users_cbx, users_tds):
            if found_username.lower().strip() == username.lower().strip():
                break
        else:
            # Did not find
            msg = "It seems there is no user named {0}".format(username)
            with FailureManager(exit_on_failure, msg):
                raise KeywordError(msg)

        # Ok, we heve a suitable checkbox_id, we select user and operation
        sel.select_checkbox('id={0}'.format(checkbox_id))
        sel.select_from_list('id=edit-operation', 'cancel')

        # Kick the form
        sel.submit_form('id=user-admin-account')

        # Checking the deletion policy
        with FailureManager(exit_on_failure, "Invalid user removal policy {0}".format(policy)):
            assert policy in (
                'user_cancel_block', 'user_cancel_block_unpublish', 'user_cancel_reassign', 'user_cancel_delete'
            )

        # Okay, let's now play with the deletion option and kick agan the form
        sel.select_radio_button('user_cancel_method', policy)
        sel.submit_form('user-multiple-cancel-confirm')

        # Check potential error
        msg = "Something went wrong when deleting user {0}".format(username)
        self._wait_bo_ok_status(exit_on_failure, msg)

    def logout(self):
        """Anonymizes the user
        """
        sel = self.selenium
        logout_url = urljoin(self.home_url, 'user/logout')
        sel.go_to(logout_url)

    # Privates (scenario)

    def _wait_bo_ok_status(self, exit_on_failure, message="", timeout=5):
        """Assert BO status box is OK after action
        (need to be on a BO page)
        """
        message = "{0}. (Have been waiting for {1} seconds)".format(message, timeout)
        with FailureManager(exit_on_failure, message):
            self.selenium.wait_until_element_is_visible('xpath=//div[@class="messages status"]',
                                                        timeout=timeout, error=message)

    # Privates (technical)

    def _actual_html(self, parsed=True):
        """Returns the actual raw or parsed HTML of the browser
        """
        html_source = self._selenium_browser.get_page_source()
        if parsed:
            return etree.HTML(html_source)
        else:
            return html_source

    @property
    def _selenium_browser(self):
        """The instance of selenium browser actually running to get a fine grained control
        """
        return self.selenium._current_browser()
开发者ID:alterway,项目名称:robotframework-drupallibrary,代码行数:104,代码来源:drupalkeywords.py

示例4: Common

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import wait_until_element_is_visible [as 别名]
class Common(object):

    def __init__(self):
        # self._seleniumLib = BuiltIn().get_library_instance("lib.ExtendedSelenium2Library")
        self._selenium2Library = BuiltIn().get_library_instance("selenium2Library")

        # _title = self._seleniumLib.get_title()
        # logger.info("Working on page: %s" % (_title))
        self.elements = {
                 'btnLogout' : "yucs-signout",
                 'lblProfile' : "xpath=//a[@aria-label='Profile']",
                 'treeNavigation' : 'storm-listnav',
                 'btnSignIn' : 'login-signin',
                 'formLogin' : 'mbr-login-form',
                 'btnEmptyTrash' : 'btn-emptytrash',
                'btnEmptySpam' : 'btn-emptyspam',
                'btnConfirmOK': 'okayModalOverlay',
                'btnConfirmCancel': 'cancelModalOverlay',
                 'txtTemp' : ''
        }

    '''
    Usage: Log out
    '''
    def logout(self):
        self._selenium2Library.javascript_click(self.elements['lblProfile'], 'click')
        self._selenium2Library.wait_until_element_is_visible(self.elements['btnLogout'], 20)
        self._selenium2Library.click_element(self.elements['btnLogout'])
        #self._selenium2Library.click_element(self.elements['btnLogout'])
        self._selenium2Library.wait_until_page_load(self._selenium2Library.timeout)

    '''
    Usage: Select a node on the Navigation tree
    '''
    def select_navigation_node(self, node_name):
        # locator = 'xpath=//a[contains(@title,"' + node_name + '")]'
        # ul#storm-listnav a[title^='Sent']
        locator = "css=ul#storm-listnav a[title^='" + node_name + "']"
        locator = "xpath=//*[@id='storm-listnav']//*[starts-with(.,'"+ node_name + "')]"
        self._selenium2Library.click_element(locator)
        self._selenium2Library.wait_until_page_load(self._selenium2Library.timeout)

    '''
    Usage: Select a menu item on the master menu (most top horizontal navigation)
    '''
    def select_master_menu_item(self, menu_item):
        locator = 'xpath=//a[contains(text(),"' + menu_item + '")]'
        # The following css locators don't work. Don't know why :(
        # masterNav [id$=news]
        # locator = "css=#masterNav [id~=" + menu_item.lower() + "]"
        # locator = "css=#yucs-top-" + menu_item.lower()
        self._selenium2Library.click_link(locator)
        self._selenium2Library.wait_until_page_load(self._selenium2Library.timeout)

    '''
    Usage: Click button on the Yahoo Mail toolbar button.
    '''
    def click_toolbar_item(self, item_name):
        # Example: li[title=Mail]
        locator = 'css=li[title='+item_name+']'
        self._selenium2Library.click_element(locator)
        self._selenium2Library.wait_until_page_load(self._selenium2Library.timeout)

    '''
    Usage: Empty the Trash folder
    '''
    def empty_trash(self, confirm = True):
        locator = "css=ul#storm-listnav a[title^='Trash']"
        self._selenium2Library.mouse_over(locator)
        self._selenium2Library.wait_until_element_is_visible(self.elements['btnEmptyTrash'], 10)
        self._selenium2Library.click_element(self.elements['btnEmptyTrash'])
        if bool(confirm):
            self._selenium2Library.click_element(self.elements['btnConfirmOK'])
        else:
            self._selenium2Library.click_element(self.elements['btnConfirmCancel'])

    '''
    Usage: Empty the Spam folder
    '''
    def empty_spam(self, confirm=True):
        locator = "css=ul#storm-listnav a[title^='Spam']"
        self._selenium2Library.mouse_over(locator)
        self._selenium2Library.wait_until_element_is_visible(self.elements['btnEmptySpam'], 10)
        self._selenium2Library.click_element(self.elements['btnEmptySpam'])
        logger.info(confirm)
        if bool(confirm):
            self._selenium2Library.click_element(self.elements['btnConfirmOK'])
        else:
            self._selenium2Library.click_element(self.elements['btnConfirmCancel'])
开发者ID:vumvo,项目名称:MyFirstGitHub,代码行数:91,代码来源:Common.py

示例5: _BrowserManagementKeywords

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import wait_until_element_is_visible [as 别名]
class _BrowserManagementKeywords(KeywordGroup):
    def __init__(self):      
        self._remoteBrowser = os.environ.get("PYBROWSER", "0") == "0"
        self._job_id = 0
        self._sauce_rest = SauceRestWrapper()
        self._seleniumlib = BuiltIn().get_library_instance('Selenium2Library')
       
    def open_pyro_browser(self, determined_browser=os.environ.get("PYBROWSER", 'firefox'), selenium_speed=0.5):
        """Opens a browser in the context determined by the suite; such as, Sauce Miltiple, Sauce Single, Sauce Solo, Local Solo and add it to Selenium2Library the browser cache.
        
        If the Robot Framework test code is executed through TeamCity using Sauce CI, the browser will be remotely instantiated throgh the Sauce service. Visit the documentation in the intro to see how the username and key are obtained
        See https://saucelabs.com/login
        
        Returns the index of this browser instance which can be used later to
        switch back to it. Index starts from 1 and is reset back to it when
        `Close All Browsers` keyword is used. See `Switch Browser` for
        example.

        Optional alias is an alias for the browser instance and it can be used
        for switching between browsers (just as index can be used). See `Switch
        Browser` for more details.

        Possible values for local instance `browser` are as follows:

        | firefox          | FireFox   |
        | ff               | FireFox   |
        | internetexplorer | Internet Explorer |
        | ie               | Internet Explorer |
        | googlechrome     | Google Chrome |
        | gc               | Google Chrome |
        | chrome           | Google Chrome |
        | opera            | Opera         |
        | phantomjs        | PhantomJS     |
        | htmlunit         | HTMLUnit      |
        | htmlunitwithjs   | HTMLUnit with Javascipt support |
        | android          | Android       |
        | iphone           | Iphone        |
        | safari           | Safari        |
        
        Note, that you will encounter strange behavior, if you open
        multiple Internet Explorer browser instances. That is also why
        `Switch Browser` only works with one IE browser at most.
        For more information see:
        http://selenium-grid.seleniumhq.org/faq.html#i_get_some_strange_errors_when_i_run_multiple_internet_explorer_instances_on_the_same_machine

        Optional 'ff_profile_dir' is the path to the firefox profile dir if you
        wish to overwrite the default.
        
        Command Line Supercede:
        IMPLICIT_WAIT (Set Selenium Implicit Wait) [can be set in import]
        COMMAND_DELAY (Set Selenium Speed) 
        KEYWORD_TIMEOUT (Set Selenium Timeout) [can be set in import]
        """
        
        print '(open_pyro_browser)'
        if self._remoteBrowser: #sauce            
            self._seleniumlib.open_browser(os.environ['BASE_URL'], browser=determined_browser, remote_url=os.environ["PYROBOT_REMOTE_URL"], desired_capabilities=os.environ["PYROBOT_CAPS"])       
            self._job_id = self._seleniumlib._current_browser().session_id
        else:                   #local solo            
            self._seleniumlib.open_browser(os.environ['BASE_URL'], browser=determined_browser) 
            
        if os.environ.get('SAUCE_API_KEY') and os.environ.get('SAUCE_USERNAME') and self._remoteBrowser:
            print "execute sauce rest to update"
            self._sauce_rest.establish(self._seleniumlib._current_browser().session_id, os.environ.get('SAUCE_USERNAME'), os.environ.get('SAUCE_API_KEY'), sys.argv[2])
            self._sauce_rest.dump_session_id()
            #ondemand_string = "SauceOnDemandSessionID=%s job-name=%s" % (self._job_id, BuiltIn().get_variable_value("${SUITE_NAME}"))
            #print 'setting ONDEMAND_PYRO to : %s' % ondemand_string
            #OperatingSystem().set_environment_variable("ONDEMAND_PYRO", "1111")    
            #os.environ['ONDEMAND_PYRO'] = ondemand_string
        
        self._seleniumlib.maximize_browser_window()
        # Determine timeouts based on commandline
        # IMPLICIT_WAIT
        # COMMAND_DELAY
        # KEYWORD_TIMEOUT
        if 'IMPLICIT_WAIT' in os.environ:
            self._seleniumlib.set_selenium_implicit_wait(os.environ.get('IMPLICIT_WAIT')) 
        if 'COMMAND_DELAY' in os.environ:
            self._seleniumlib.set_selenium_speed(os.environ.get('COMMAND_DELAY')) 
        else:
            print '(open_pyro_browser) setting selenium speed %s' % selenium_speed
            self._seleniumlib.set_selenium_speed(selenium_speed) 
        if 'KEYWORD_TIMEOUT' in os.environ:
            self._seleniumlib.set_selenium_timeout(os.environ.get('KEYWORD_TIMEOUT')) 

    def sencha_login(self, user_name, password, element_on_next_page, suspend_timeouts=True):
    #def sencha_login(self, user_name, password, element_on_next_page):
        """
        Using the instantiated browser from `Open Browser`, the page traverses through the login page and waits for the targeted element on the following page.
        """
        print '(login_sencha)'
        self._seleniumlib.wait_until_element_is_visible('loginnameid-inputEl', timeout=5)
        self._seleniumlib.wait_until_element_is_visible('loginpasswordid-inputEl', timeout=5)
        self._seleniumlib.input_text('loginnameid-inputEl', user_name)
        self._seleniumlib.input_text('loginpasswordid-inputEl', password)
        self._seleniumlib.wait_until_element_is_visible('loginbuttonid-btnIconEl', timeout=5)
        self._seleniumlib.click_element('id=loginbuttonid-btnIconEl')
        self._seleniumlib.wait_until_element_is_visible('id=%s'% element_on_next_page, timeout=5)
        if suspend_timeouts == True:
            print '(login_sencha) javascript issuing suspendAll!'
#.........这里部分代码省略.........
开发者ID:Tallisado,项目名称:pyrolibrary,代码行数:103,代码来源:_browsermanagement.py

示例6: Inbox

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

#.........这里部分代码省略.........
    '''
    def select_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 + "']/ancestor::div[3]//input"
        checkboxes = email_table.find_elements(By.XPATH, xpath_locator)
        for chk_select in checkboxes:
            if not chk_select.is_selected():
                    chk_select.click()

    '''
    Usage: Open email by subject
    '''
    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)
开发者ID:vumvo,项目名称:MyFirstGitHub,代码行数:70,代码来源:Inbox.py


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