def run_browserstack(self, os_name, os_version, browser, browser_version,
                         remote_project_name, remote_build_name):
        "Run the test in browser stack when remote flag is 'Y'"
        "在线平台要花钱,忽略"
        #Get the browser stack credentials from browser stack credentials file
        USERNAME = remote_credentials.USERNAME
        PASSWORD = remote_credentials.ACCESS_KEY
        if browser.lower() == 'ff' or browser.lower() == 'firefox':
            desired_capabilities = DesiredCapabilities.FIREFOX
        elif browser.lower() == 'ie':
            desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
        elif browser.lower() == 'chrome':
            desired_capabilities = DesiredCapabilities.CHROME
        elif browser.lower() == 'opera':
            desired_capabilities = DesiredCapabilities.OPERA
        elif browser.lower() == 'safari':
            desired_capabilities = DesiredCapabilities.SAFARI
        desired_capabilities['os'] = os_name
        desired_capabilities['os_version'] = os_version
        desired_capabilities['browser_version'] = browser_version
        if remote_project_name is not None:
            desired_capabilities['project'] = remote_project_name
        if remote_build_name is not None:
            desired_capabilities['build'] = remote_build_name + "_" + str(
                datetime.now().strftime("%c"))

        return webdriver.Remote(
            RemoteConnection("http://%s:%[email protected]/wd/hub" %
                             (USERNAME, PASSWORD),
                             resolve_ip=False),
            desired_capabilities=desired_capabilities)
    def run_browserstack(self, os_name, os_version, browser, browser_version):
        "Run the test in browser stack when remote flag is 'Y'"
        #Get the browser stack credentials from browser stack credentials file
        USERNAME = remote_credentials.USERNAME
        PASSWORD = remote_credentials.ACCESS_KEY
        if browser.lower() == 'ff' or browser.lower() == 'firefox':
            desired_capabilities = DesiredCapabilities.FIREFOX
        elif browser.lower() == 'ie':
            desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
        elif browser.lower() == 'chrome':
            desired_capabilities = DesiredCapabilities.CHROME
        elif browser.lower() == 'opera':
            desired_capabilities = DesiredCapabilities.OPERA
        elif browser.lower() == 'safari':
            desired_capabilities = DesiredCapabilities.SAFARI

        desired_capabilities['os'] = os_name
        desired_capabilities['os_version'] = os_version
        desired_capabilities['browser_version'] = browser_version

        return webdriver.Remote(
            RemoteConnection("http://%s:%[email protected]/wd/hub" %
                             (USERNAME, PASSWORD),
                             resolve_ip=False),
            desired_capabilities=desired_capabilities)
    def run_browserstack(self, os_name, os_version, browser, browser_version,
                         remote_project_name, remote_build_name):
        """Run the test in browser stack when remote flag is 'Y'."""
        #Get the browser stack credentials from browser stack credentials file
        username = remote_credentials.USERNAME
        password = remote_credentials.ACCESS_KEY

        #Set browser
        desired_capabilities = self.get_browser(browser, browser_version)

        #Set os and os_version
        desired_capabilities = self.set_os(desired_capabilities, os_name,
                                           os_version)

        #Set remote project name
        if remote_project_name is not None:
            desired_capabilities = self.remote_project_name(
                desired_capabilities, remote_project_name)

        #Set remote build name
        if remote_build_name is not None:
            desired_capabilities = self.remote_build_name(
                desired_capabilities, remote_build_name)

        web_driver = webdriver.Remote(
            RemoteConnection("http://%s:%[email protected]/wd/hub" %
                             (username, password),
                             resolve_ip=False),
            desired_capabilities=desired_capabilities)

        return web_driver