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


Python BuiltIn.click_element方法代码示例

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


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

示例1: select_the_row

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import click_element [as 别名]
 def select_the_row(self, table_locator, rowNo):
     "Returns the text located in the table 'table_locator' with in the Column 'columnName' and matching Row 'iRowNo'" ""
     selenium = BuiltIn().get_library_instance("Selenium2Library")
     return selenium.click_element(
         table_locator
         + '/div[@class="dgrid-scroller"]/div[contains(@class,"dgrid-content")]//div[contains(@id,"-row")]['
         + str(rowNo)
         + "]"
     )
开发者ID:Tenxlabsmm,项目名称:Demo,代码行数:11,代码来源:CommonLibrary.py

示例2: open_popup

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import click_element [as 别名]
def open_popup(locator):
    """ 
    Clicks a web element that will open a new popup window.
    """
    seleniumlib = BuiltIn().get_library_instance('Selenium2Library')
    browser = seleniumlib._current_browser()
    #saves the main window handle to an instance variablec
    seleniumlib.main_window = browser.current_window_handle
    logger.debug('Current window handle is: %s' % seleniumlib.main_window)
    before = set(browser.window_handles)
    seleniumlib.click_element(locator)
    after = set(browser.window_handles) 
    try:
        new_win = (after - before).pop()
    except KeyError:
        logger.warn("No new popup window was detected!")
        raise
    logger.debug('Switching to window: %s' % new_win)
    browser.switch_to_window(new_win)
开发者ID:gokusenz,项目名称:s2l_GhostDriver_extensions,代码行数:21,代码来源:ghost_extensions.py

示例3: Common

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import click_element [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

示例4: _BrowserManagementKeywords

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import click_element [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

示例5: Inbox

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import click_element [as 别名]
class Inbox(object):
    """
    High level action for Inbox page
    """

    def __init__(self):
        self._selenium2Library = BuiltIn().get_library_instance('selenium2Library')
        self.elements = {
                 'txtTemp' : '',
                'mail_rows' : 'css=div[class^="list-view-item-container ml-bg"]',
                'mail_table' : 'msg-list',
                'btn_popup_category' : 'btn-select-dd',
                'btn_compose' : "css=button[data-action='compose']",
                'txt_to_field' : 'to-field',
                'txt_cc_field' : 'cc-field',
                'txt_bcc_field' : 'bcc-field',
                'txt_subject_field' : 'subject-field',
                'txt_body_field' : 'rtetext',
                'btn_send' : "css=span[data-action='send']",
                'lbl_from' : "css=div.thread-item-header span[aria-label*='from ']",
                'txt_mail_content' : 'css=div.email-wrapped',
                'btn_delete' : 'btn-delete'

        }
    '''
    Usage: Select the email based on row index. 1st-based index.
    '''
    def select_email_by_index(self, row_index = 1):
        locator = self.elements['mail_rows']
        rows = self._selenium2Library.element_find(locator, False, False, None)
        chk_select = rows[int(row_index)-1].find_element(By.CSS_SELECTOR, "input[role='checkbox']" )
        if not chk_select.is_selected():
            chk_select.click()

    '''
    Usage: Select mass emails whose sender is matched with the sender_name
    Note: This keyword couldn't select the all the emails if there are too many.
    '''
    def select_email_by_sender(self, sender_name):
        locator = self.elements['mail_rows']
        my_rows = self._selenium2Library.element_find(locator, False, False, None)
        logger.info(str(len(my_rows)))
        length = len(my_rows)
        print my_rows
        for i in range(len(my_rows)):
            # BuiltIn().sleep(1, "New Row----")
            # logger.info("Row: " + str(i))
            # logger.info(str(len(my_rows)))
            row = my_rows[i]
            # logger.info(str(row))
            self._selenium2Library.wait_until_element_is_displayed(row, self._selenium2Library.timeout)
            element_sender = row.find_element(By.XPATH, ".//div[starts-with(@class,'from')]")
            # logger.info("Found element_sender.")
            self._selenium2Library.wait_until_element_is_displayed(element_sender,
                                                                   self._selenium2Library.timeout)
            # logger.info("Is Sender element displayed? " + str(element_sender.is_displayed()))
            current_sender_name = element_sender.text.strip()
            # logger.info("Current Sender Name: " + current_sender_name)
            if current_sender_name == sender_name:
                # logger.info("Found matched")
                chk_select = row.find_element(By.XPATH, ".//input[@role='checkbox']")
                if not chk_select.is_selected():
                    chk_select.click()
            # Refresh the rows list
            my_rows = self._selenium2Library.element_find(locator, False, False, None)

    '''
    Usage: Select the 1st email whose title is matched with the input.
    '''
    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'])
#.........这里部分代码省略.........
开发者ID:vumvo,项目名称:MyFirstGitHub,代码行数:103,代码来源:Inbox.py

示例6: click_on_element

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import click_element [as 别名]
 def click_on_element(self,elementLocator,timeout="60s"):
     selenium = BuiltIn().get_library_instance('Selenium2Library')
     selenium.wait_until_page_contains_element(elementLocator,timeout)
     selenium.click_element(elementLocator)
开发者ID:Tungalasriharibabu,项目名称:MM1,代码行数:6,代码来源:TableData.py

示例7: select_value_in_table

# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import click_element [as 别名]
 def select_value_in_table(self, table_locator, columnNo, RowNo):
     selenium = BuiltIn().get_library_instance('Selenium2Library')
     selenium.click_element('//span[contains(text(),"Available Students")]//following::div//div//table//th[5]//following::div['+str(columnNo)+']//table//td['+str(RowNo)+']')
开发者ID:Tungalasriharibabu,项目名称:MM1,代码行数:5,代码来源:TableData.py


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