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


Python BuiltIn.set_selenium_speed方法代码示例

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


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

示例1: _BrowserManagementKeywords

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


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