python类Remote()的实例源码

Container.py 文件源码 项目:devsecops-example-helloworld 作者: boozallen 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _webdriver(self):
        className = self._driverClassName()
        self._remoteUsername = self._remoteUsername()
        remoteURL = self._remoteURL()
        capabilities = self._capabilities()
        if remoteURL:
            self.log("RemoteURL")
            # Remote driver requires a executor (typically a Remote URL)
            browserProfile = FirefoxProfile()
            return webdriver.Remote(command_executor = remoteURL, keep_alive = True, \
                browser_profile = browserProfile, desired_capabilities = capabilities)
        clazz = self._driverClass(className)
        try:
            self.log("" + className + "(capabilities)")
            return clazz(desired_capabilities = capabilities)
        except Exception:
            self.log("Setting up " + className)
            if className == 'PhantomJS':
                # PhantomJS cannot handle capabilities
                self.log("Creating " + className)
                return clazz()
            else:
                # Firefox and Ie drivers have different name for desired capabilities parameter
                #return clazz(capabilities = capabilities)
                return clazz()
horizon_test.py 文件源码 项目:kolla-kubernetes 作者: openstack 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def getDriver(self):
        count = 0
        while(True):
            try:
                ce = "http://%s:4444/wd/hub" % os.environ["HUB"]
                driver = webdriver.Remote(
                    command_executor=ce,
                    desired_capabilities={
                        "browserName": os.environ.get("browser", "firefox"),
                        "platform": "Linux"
                    }
                )
                return driver
            except WebDriverException as e:
                s = "%s" % e
                print("Got exception %s" % s)
                print("%s" % dir(s))
                if "Empty pool of VM for setup Capabilities" not in s:
                    raise
                time.sleep(5)
            if count == 60:
                raise Exception("Time out trying to get a browser")
            count += 1
instapy.py 文件源码 项目:InstaPy 作者: timgrossmann 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def set_selenium_remote_session(self, selenium_url=''):
        """Starts remote session for a selenium server.
         Useful for docker setup."""
        if self.aborting:
            return self

        if self.use_firefox:
            self.browser = webdriver.Remote(
                command_executor=selenium_url,
                desired_capabilities=DesiredCapabilities.FIREFOX)
        else:
            self.browser = webdriver.Remote(
                command_executor=selenium_url,
                desired_capabilities=DesiredCapabilities.CHROME)

        self.logger.info('Session started - %s'
                         % (datetime.now().strftime('%Y-%m-%d %H:%M:%S')))

        return self
SeleniumDrivers.py 文件源码 项目:AutoTriageBot 作者: salesforce 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self):
        try:
            self.driver = webdriver.Remote(command_executor='http://firefox:4444/wd/hub',
                                           desired_capabilities=DesiredCapabilities.FIREFOX)
        except URLError as e:
            print("Failed to connect!")
            raise e
SeleniumDrivers.py 文件源码 项目:AutoTriageBot 作者: salesforce 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def __init__(self):
        try:
            self.driver = webdriver.Remote(command_executor='http://chrome:4444/wd/hub',
                                           desired_capabilities=DesiredCapabilities.CHROME)
        except URLError as e:
            print("Failed to connect!")
            raise e
browser.py 文件源码 项目:vanguard-api 作者: rikonor 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def start(self):
        self.driver = webdriver.Remote(
           command_executor=self.remote,
           desired_capabilities=self.browser_type)
browser_mgmt.py 文件源码 项目:warriorframework 作者: warriorframework 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _create_remote_web_driver(self, capabilities_type, webdriver_remote_url,
                                  desired_capabilities=None, profile=None):
        """parses the string based desired_capabilities if neccessary and
        creates the associated remote web driver"""

        desired_capabilities_object = capabilities_type.copy()

        if isinstance(desired_capabilities, (str, unicode)):
            desired_capabilities = self._parse_capabilities_string(desired_capabilities)

        desired_capabilities_object.update(desired_capabilities or {})

        return webdriver.Remote(desired_capabilities=desired_capabilities_object,
                                command_executor=str(webdriver_remote_url),
                                browser_profile=profile)
test_bots.py 文件源码 项目:Dallinger 作者: Dallinger 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_bot_using_webdriver_phantomjs(self):
        """Create a bot."""
        config.ready = True
        config.extend({
            'webdriver_type': u'phantomjs',
            'webdriver_url': pytest.config.getvalue("webdriver").decode("ascii")
        })
        from dallinger.bots import BotBase
        bot = BotBase("http://dallinger.io")
        assert isinstance(bot.driver, webdriver.Remote)
        assert bot.driver.capabilities['browserName'] == 'phantomjs'
test_bots.py 文件源码 项目:Dallinger 作者: Dallinger 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_bot_using_webdriver_firefox(self):
        """Create a bot."""
        config.ready = True
        config.extend({
            'webdriver_type': u'firefox',
            'webdriver_url': pytest.config.getvalue("webdriver").decode("ascii")
        })
        from dallinger.bots import BotBase
        bot = BotBase("http://dallinger.io")
        assert isinstance(bot.driver, webdriver.Remote)
        assert bot.driver.capabilities['browserName'] == 'firefox'
test_bots.py 文件源码 项目:Dallinger 作者: Dallinger 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_bot_using_webdriver_chrome(self):
        """Create a bot."""
        config.ready = True
        config.extend({
            'webdriver_type': u'chrome',
            'webdriver_url': pytest.config.getvalue("webdriver").decode("ascii")
        })
        from dallinger.bots import BotBase
        bot = BotBase("http://dallinger.io")
        assert isinstance(bot.driver, webdriver.Remote)
        assert bot.driver.capabilities['browserName'] == 'chrome'
bots.py 文件源码 项目:Dallinger 作者: Dallinger 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def driver(self):
        """Returns a Selenium WebDriver instance of the type requested in the
        configuration."""
        from dallinger.config import get_config
        config = get_config()
        if not config.ready:
            config.load()
        driver_url = config.get('webdriver_url', None)
        driver_type = config.get('webdriver_type', 'phantomjs').lower()

        if driver_url:
            capabilities = {}
            if driver_type == 'firefox':
                capabilities = webdriver.DesiredCapabilities.FIREFOX
            elif driver_type == 'chrome':
                capabilities = webdriver.DesiredCapabilities.CHROME
            elif driver_type == 'phantomjs':
                capabilities = webdriver.DesiredCapabilities.PHANTOMJS
            else:
                raise ValueError(
                    'Unsupported remote webdriver_type: {}'.format(driver_type))
            driver = webdriver.Remote(
                desired_capabilities=capabilities,
                command_executor=driver_url
            )
        elif driver_type == 'phantomjs':
            driver = webdriver.PhantomJS()
        elif driver_type == 'firefox':
            driver = webdriver.Firefox()
        elif driver_type == 'chrome':
            driver = webdriver.Chrome()
        else:
            raise ValueError(
                'Unsupported webdriver_type: {}'.format(driver_type))
        driver.set_window_size(1024, 768)
        logger.info("Created {} webdriver.".format(driver_type))
        return driver
seleniumtest.py 文件源码 项目:Skynet2.0 作者: Skynet2-0 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        self.driver = webdriver.Remote(
        command_executor='http://127.0.0.1:4444/wd/hub',
        desired_capabilities=DesiredCapabilities.FIREFOX)
        pass
VPSBuyer.py 文件源码 项目:Skynet2.0 作者: Skynet2-0 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def spawnBrowser(self):
        """Spawns the browser to use when internetting."""
        self.driver = webdriver.Remote(
            command_executor='http://127.0.0.1:4444/wd/hub',
            desired_capabilities=DesiredCapabilities.FIREFOX)
chromedriver.py 文件源码 项目:ATX 作者: NetEaseGame 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def driver(self, package=None, attach=True, activity=None, process=None):
        """
        Args:
            - package(string): default current running app
            - attach(bool): default true, Attach to an already-running app instead of launching the app with a clear data directory
            - activity(string): Name of the Activity hosting the WebView.
            - process(string): Process name of the Activity hosting the WebView (as given by ps). 
                If not given, the process name is assumed to be the same as androidPackage.

        Returns:
            selenium driver
        """
        app = self._d.current_app()
        capabilities = {
            'chromeOptions': {
                'androidDeviceSerial': self._d.serial,
                'androidPackage': package or app.package,
                'androidUseRunningApp': attach,
                'androidProcess': process or app.package,
                'androidActivity': activity or app.activity,
            }
        }

        try:
            dr = webdriver.Remote('http://localhost:%d' % self._port, capabilities)
        except URLError:
            self._launch_webdriver()
            dr = webdriver.Remote('http://localhost:%d' % self._port, capabilities)

        # always quit driver when done
        atexit.register(dr.quit)
        return dr
fbscrape.py 文件源码 项目:open-source-feeds 作者: mhfowler 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def initialize_driver(self, driver=None):
        if self.command_executor:
            chrome_options = Options()
            chrome_options.add_argument("--disable-notifications")
            if self.proxy:
                chrome_options.add_argument('--proxy-server=%s' % self.proxy)
            self.driver = webdriver.Remote(
                command_executor=self.command_executor,
                desired_capabilities=chrome_options.to_capabilities()
            )
        else:
            if self.which_driver == 'phantomjs':
                dcap = dict(DesiredCapabilities.PHANTOMJS)
                dcap["phantomjs.page.settings.userAgent"] = (
                    "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 "
                    "(KHTML, like Gecko) Chrome/15.0.87"
                )
                driver = webdriver.PhantomJS(desired_capabilities=dcap)
                driver.set_window_size(1400, 1000)
                self.driver = driver
            elif self.which_driver == 'chrome':
                chrome_options = Options()
                chrome_options.add_argument("--disable-notifications")
                if self.proxy:
                    chrome_options.add_argument('--proxy-server=%s' % self.proxy)
                self.driver = webdriver.Chrome(chrome_options=chrome_options)
            # otherwise use the driver passed in
            else:
                self.driver = driver
        # set page load timeout
        self.driver.set_page_load_timeout(time_to_wait=240)
conftest.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def selenium(request: FixtureRequest) -> webdriver.Remote:
    if request.config.getoption('--local-chrome'):
        driver = initialize_local_chrome()
        request.addfinalizer(lambda: deinitialize_selenium(driver))
        return driver
    driver = request.getfixturevalue('selenium')  # type: webdriver.Remote
    yield driver
    # https://github.com/SeleniumHQ/docker-selenium/issues/87#issuecomment-286231268
    driver.close()
test_entities_page.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 63 收藏 0 点赞 0 评论 0
def setup(self, base_url: str, console_ip: str, pages: PageObjectContainer, selenium: webdriver.Remote):
        self.base_url = base_url
        self.console_ip = console_ip
        self.console_port = 5673
        self.ConnectPage = pages.connect_page
        self.OverviewPage = pages.overview_page
        self.EntitiesPage = pages.entities_page
        self.selenium = selenium
        self.test_name = None
        return self
test_hawtio_logs_page.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def setup(self, base_url: str, console_ip: str, pages: PageObjectContainer, selenium: webdriver.Remote):
        self.base_url = base_url
        self.console_ip = console_ip
        self.LogsPage = pages.logs_page
        self.selenium = selenium
        self.test_name = None
        return self
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, selenium: webdriver.Remote):
        self.selenium = selenium
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def wait(cls, selenium: webdriver.Remote):
        locator = (By.CSS_SELECTOR, '.active a[ng-href="#/logs"]')
        WebDriverWait(selenium, 30).until(EC.visibility_of_element_located(locator))
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def wait(cls, selenium: webdriver.Remote):
        # wait for Connect link in the top bar to be active
        locator = (By.CSS_SELECTOR, '.active a[ng-href="#/{}/connect"]'.format(PLUGIN_NAME))
        WebDriverWait(selenium, 30).until(EC.presence_of_element_located(locator))
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, selenium: webdriver.Remote):
        super().__init__(selenium)
        self.node_count = None  # type: int
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, selenium: webdriver.Remote):
        super().__init__(selenium)
        self.node_count = 5
        # Wait for at least one node expander to appear
        _ = self.wait_locate_visible_element(self.expander_locator)
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def wait(cls, selenium: webdriver.Remote):
        # wait for Overview link in the top bar to be active
        locator = (By.CSS_SELECTOR, '.active a[ng-href="#/{}/overview"]'.format(PLUGIN_NAME))
        WebDriverWait(selenium, 30).until(EC.presence_of_element_located(locator))
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, selenium: webdriver.Remote):
        super().__init__(selenium)
        self.node_count = 17
        # Wait for at least one node expander to appear
        _ = self.wait_locate_visible_element(self.expander_locator)
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, selenium: webdriver.Remote):
        super().__init__(selenium)
        # Wait for at least one node expander to appear
        _ = self.wait_locate_visible_element(self.expander_locator)
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def wait(cls, selenium: webdriver.Remote):
        # wait for Overview link in the top bar to be active
        locator = (By.CSS_SELECTOR, 'li.active > a[ng-href="#!/overview"]')
        WebDriverWait(selenium, 30).until(EC.presence_of_element_located(locator))
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, selenium: webdriver.Remote):
        super().__init__(selenium)
        # Wait for at least one node expander to appear
        _ = self.wait_locate_visible_element(self.expander_locator)
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def wait(cls, selenium: webdriver.Remote):
        # wait for Overview link in the top bar to be active
        locator = (By.CSS_SELECTOR, 'li.active > a[ng-href="#!/list"]')
        WebDriverWait(selenium, 30).until(EC.presence_of_element_located(locator))
page_objects.py 文件源码 项目:dispatch-console-tests 作者: jdanekrh 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, selenium: webdriver.Remote):
        super().__init__(selenium)


问题


面经


文章

微信
公众号

扫码关注公众号