示例#1
0
def fireBrowserWithSize(step):
    width, height = getWidthHeightFromCMDArgs(world.window_params)
    if world.cli_params and world.cli_params == "chrome":
        print "Creating %s browser with %s width, %s height" % (world.cli_params, width, height)
        # world.browser = initiateChromeWithSize(int(width), int(height))
        # world.browser.set_window_size(int(width), int(height))
        world.browser = webdriver.Chrome()
    elif world.cli_params and world.cli_params == "firefox":
        world.browser = webdriver.Firefox()
    elif world.cli_params and world.cli_params == "phantom":
        world.browser = webdriver.PhantomJS()
        time.sleep(5)
    else :
        # world.browser = webdriver.Safari('../standalone.jar')
        from pprint import pprint
        # pprint(world.browser.options.__dict__)
        from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
        safari_capabilities = {'platform': 'ANY',
                               'browserName': 'safari', 
                               'version': '', 
                               'javascriptEnabled': True,
                                'webdriver_accept_untrusted_certs' : True,
                                'acceptSslCerts' : True,
                                'trustAllSSLCertificates' :True
                               }

        # safari_capabilities['loggingPrefs'] = {'browser': 'OFF', 'server': 'OFF', 'driver': "OFF"}
        # FOR MORE DETAILS VISIT https://code.google.com/p/selenium/wiki/DesiredCapabilities
        # Available values for most loggers are "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST", "ALL".
        # This produces a JSON object looking something like: {"loggingPrefs": {"driver": "INFO", "server": "OFF", "browser": "FINE"}}.
        # world.browser = webdriver.Remote(
        #    command_executor='http://192.168.42.72:4444/wd/hub',
        #    desired_capabilities=safari_capabilities)
        world.browser = webdriver.Safari('../standalone.jar')

    world.browser.set_window_size(int(width), int(height))
示例#2
0
def checkPosition(step,size):
    width, height = getWidthHeightFromCMDArgs(size)
    # print "Creating %s browser with %s width, %s height" % (size, width, height)
    world.browser.set_window_size(int(width), int(height))
    step.given('I refresh browser')
    step.given('And wait 1 seconds')