def createWebDriver(self):
        if 'SELENIUM_STARTING_URL' not in os.environ:
            startingUrl = "http://saucelabs.com"
        else:
            startingUrl = os.environ['SELENIUM_STARTING_URL']

        if 'SELENIUM_DRIVER' in os.environ and 'SELENIUM_HOST' in os.environ and 'SELENIUM_PORT' in os.environ:
            parse = ParseSauceURL(os.environ["SELENIUM_DRIVER"])

            browser = os.environ["SELENIUM_BROWSER"]
            desired_capabilities = {}

            desired_capabilities['browserName'] = browser
            desired_capabilities['version'] = os.environ["SELENIUM_VERSION"]

            if 'SELENIUM_PLATFORM' in os.environ:
                desired_capabilities['platform'] = os.environ['SELENIUM_PLATFORM']
            else:
            #work around for name issues in Selenium 2
                if 'Windows 2003' in parse.getOS():
                    desired_capabilities['platform'] = 'XP'
                elif 'Windows 2008' in parse.getOS():
                    desired_capabilities['platform'] = 'VISTA'
                elif 'Linux' in parse.getOS():
                    desired_capabilities['platform'] = 'LINUX'
                else:
                    desired_capabilities['platform'] = parse.getOS()

            desired_capabilities['name'] = parse.getJobName()

            command_executor="http://%s:%s@%s:%s/wd/hub"%(os.environ['SAUCE_USER_NAME'], os.environ['SAUCE_API_KEY'], os.environ['SELENIUM_HOST'], os.environ['SELENIUM_PORT'])

            #make sure the test doesn't run forever if if the test crashes
            if parse.getMaxDuration() != 0:
                desired_capabilities['max-duration'] = parse.getMaxDuration()
                desired_capabilities['command-timeout'] = parse.getMaxDuration()

            if parse.getIdleTimeout() != 0:
                desired_capabilities['idle-timeout'] = parse.getIdleTimeout()

            driver=webdriver.Remote(desired_capabilities=desired_capabilities, command_executor=command_executor)
            driver.get(startingUrl)
            wrapper = Wrapper(driver, parse)
            wrapper.dump_session_id()
            return wrapper

        else:
            return webdriver.Firefox()
	def test_parse(self):
		parse = ParseSauceURL(self.url)
		self.assertEqual("simple test", parse.getJobName())
		self.assertEqual("Linux", parse.getOS())
		self.assertEqual("firefox", parse.getBrowser())
		self.assertEqual("7", parse.getBrowserVersion())
		self.assertEqual("", parse.getFirefoxProfileURL())
		self.assertEqual(300, parse.getMaxDuration())
		self.assertEqual(90, parse.getIdleTimeout())
		self.assertEqual("", parse.getUserExtensionsURL())
示例#3
0
 def test_parse(self):
     parse = ParseSauceURL(self.url)
     self.assertEqual("foobar", parse.getUserName())
     self.assertEqual("1234-5678-9102-3456", parse.getAccessKey())
     self.assertEqual("simple test", parse.getJobName())
     self.assertEqual("Linux", parse.getOS())
     self.assertEqual("firefox", parse.getBrowser())
     self.assertEqual("7", parse.getBrowserVersion())
     self.assertEqual("", parse.getFirefoxProfileURL())
     self.assertEqual(300, parse.getMaxDuration())
     self.assertEqual(90, parse.getIdleTimeout())
     self.assertEqual("", parse.getUserExtensionsURL())
    def createWebDriver(self):
        if 'SELENIUM_STARTING_URL' not in os.environ:
            startingUrl = "http://saucelabs.com"
        else:
            startingUrl = os.environ['SELENIUM_STARTING_URL']

        if 'SELENIUM_DRIVER' in os.environ and 'SELENIUM_HOST' in os.environ and 'SELENIUM_PORT' in os.environ:
            parse = ParseSauceURL(os.environ["SELENIUM_DRIVER"])

            desired_capabilities = {}
            if parse.getBrowser() == 'android':
                desired_capabilities = webdriver.DesiredCapabilities.ANDROID
            elif parse.getBrowser() == 'googlechrome':
                desired_capabilities = webdriver.DesiredCapabilities.CHROME
            elif parse.getBrowser() == 'firefox':
                desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
            elif parse.getBrowser() == 'htmlunit':
                desired_capabilities = webdriver.DesiredCapabilities.HTMLUNIT
            elif parse.getBrowser() == 'iexplore':
                desired_capabilities = webdriver.DesiredCapabilities.INTERNETEXPLORER
            elif parse.getBrowser() == 'iphone':
                desired_capabilities = webdriver.DesiredCapabilities.IPHONE
            else:
                desired_capabilities = webdriver.DesiredCapabilities.FIREFOX

            desired_capabilities['version'] = parse.getBrowserVersion()

            if 'SELENIUM_PLATFORM' in os.environ:
                desired_capabilities['platform'] = os.environ[
                    'SELENIUM_PLATFORM']
            else:
                #work around for name issues in Selenium 2
                if 'Windows 2003' in parse.getOS():
                    desired_capabilities['platform'] = 'XP'
                elif 'Windows 2008' in parse.getOS():
                    desired_capabilities['platform'] = 'VISTA'
                elif 'Linux' in parse.getOS():
                    desired_capabilities['platform'] = 'LINUX'
                else:
                    desired_capabilities['platform'] = parse.getOS()

            desired_capabilities['name'] = parse.getJobName()

            command_executor = "http://%s:%s@%s:%s/wd/hub" % (
                parse.getUserName(), parse.getAccessKey(),
                os.environ['SELENIUM_HOST'], os.environ['SELENIUM_PORT'])

            #make sure the test doesn't run forever if if the test crashes
            if parse.getMaxDuration() != 0:
                desired_capabilities['max-duration'] = parse.getMaxDuration()
                desired_capabilities['command-timeout'] = parse.getMaxDuration(
                )

            if parse.getIdleTimeout() != 0:
                desired_capabilities['idle-timeout'] = parse.getIdleTimeout()

            driver = webdriver.Remote(
                desired_capabilities=desired_capabilities,
                command_executor=command_executor)
            driver.get(startingUrl)
            wrapper = Wrapper(driver, parse)
            wrapper.dump_session_id()
            return wrapper

        else:
            return webdriver.Firefox()
    def createWebDriver(self):
        if "SELENIUM_STARTING_URL" not in os.environ:
            startingUrl = "http://saucelabs.com"
        else:
            startingUrl = os.environ["SELENIUM_STARTING_URL"]

        if "SELENIUM_DRIVER" in os.environ and "SELENIUM_HOST" in os.environ and "SELENIUM_PORT" in os.environ:
            parse = ParseSauceURL(os.environ["SELENIUM_DRIVER"])

            desired_capabilities = {}
            if parse.getBrowser() == "android":
                desired_capabilities = webdriver.DesiredCapabilities.ANDROID
            elif parse.getBrowser() == "googlechrome":
                desired_capabilities = webdriver.DesiredCapabilities.CHROME
            elif parse.getBrowser() == "firefox":
                desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
            elif parse.getBrowser() == "htmlunit":
                desired_capabilities = webdriver.DesiredCapabilities.HTMLUNIT
            elif parse.getBrowser() == "iexplore":
                desired_capabilities = webdriver.DesiredCapabilities.INTERNETEXPLORER
            elif parse.getBrowser() == "iphone":
                desired_capabilities = webdriver.DesiredCapabilities.IPHONE
            else:
                desired_capabilities = webdriver.DesiredCapabilities.FIREFOX

            desired_capabilities["version"] = parse.getBrowserVersion()

            if "SELENIUM_PLATFORM" in os.environ:
                desired_capabilities["platform"] = os.environ["SELENIUM_PLATFORM"]
            else:
                # work around for name issues in Selenium 2
                if "Windows 2003" in parse.getOS():
                    desired_capabilities["platform"] = "XP"
                elif "Windows 2008" in parse.getOS():
                    desired_capabilities["platform"] = "VISTA"
                elif "Linux" in parse.getOS():
                    desired_capabilities["platform"] = "LINUX"
                else:
                    desired_capabilities["platform"] = parse.getOS()

            desired_capabilities["name"] = parse.getJobName()

            command_executor = "http://%s:%s@%s:%s/wd/hub" % (
                parse.getUserName(),
                parse.getAccessKey(),
                os.environ["SELENIUM_HOST"],
                os.environ["SELENIUM_PORT"],
            )

            # make sure the test doesn't run forever if if the test crashes
            if parse.getMaxDuration() != 0:
                desired_capabilities["max-duration"] = parse.getMaxDuration()
                desired_capabilities["command-timeout"] = parse.getMaxDuration()

            if parse.getIdleTimeout() != 0:
                desired_capabilities["idle-timeout"] = parse.getIdleTimeout()

            driver = webdriver.Remote(desired_capabilities=desired_capabilities, command_executor=command_executor)
            driver.get(startingUrl)
            wrapper = Wrapper(driver, parse)
            wrapper.dump_session_id()
            return wrapper

        else:
            return webdriver.Firefox()