コード例 #1
0
    def test_binary(self):
        opts = Options()
        assert opts.binary is None

        other_binary = FirefoxBinary()
        assert other_binary != opts.binary
        opts.binary = other_binary
        assert other_binary == opts.binary

        path = "/path/to/binary"
        opts.binary = path
        assert isinstance(opts.binary, FirefoxBinary)
        assert opts.binary._start_cmd == path
コード例 #2
0
    def test_to_capabilities(self):
        opts = Options()
        firefox_caps = DesiredCapabilities.FIREFOX.copy()
        firefox_caps.update({"pageLoadStrategy": "normal"})
        assert opts.to_capabilities() == firefox_caps

        profile = FirefoxProfile()
        opts.profile = profile
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "profile" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["profile"], str)
        assert caps["moz:firefoxOptions"]["profile"] == profile.encoded

        opts.add_argument("--foo")
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "args" in caps["moz:firefoxOptions"]
        assert caps["moz:firefoxOptions"]["args"] == ["--foo"]

        binary = FirefoxBinary()
        opts.binary = binary
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "binary" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["binary"], str)
        assert caps["moz:firefoxOptions"]["binary"] == binary._start_cmd

        opts.set_preference("spam", "ham")
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "prefs" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["prefs"], dict)
        assert caps["moz:firefoxOptions"]["prefs"]["spam"] == "ham"
コード例 #3
0
    def _setup_firefox(self, capabilities):
        """Setup Firefox webdriver

        :param capabilities: capabilities object
        :returns: a new local Firefox driver
        """
        if capabilities.get("marionette"):
            gecko_driver = self.config.get('Driver', 'gecko_driver_path')
            self.logger.debug("Gecko driver path given in properties: %s",
                              gecko_driver)
        else:
            gecko_driver = None

        # Get Firefox binary
        firefox_binary = self.config.get_optional('Firefox', 'binary')
        if firefox_binary:
            self.logger.debug("Using firefox binary: %s", firefox_binary)
            firefox_options = Options()
            firefox_options.binary = firefox_binary
        else:
            firefox_options = None

        return webdriver.Firefox(
            firefox_profile=self._create_firefox_profile(),
            capabilities=capabilities,
            executable_path=gecko_driver,
            firefox_options=firefox_options)
コード例 #4
0
ファイル: config_driver.py プロジェクト: jframos/toolium
    def _setup_firefox(self, capabilities):
        """Setup Firefox webdriver

        :param capabilities: capabilities object
        :returns: a new local Firefox driver
        """
        if capabilities.get("marionette"):
            gecko_driver = self.config.get('Driver', 'gecko_driver_path')
            self.logger.debug("Gecko driver path given in properties: %s", gecko_driver)
        else:
            gecko_driver = None

        # Get Firefox binary
        firefox_binary = self.config.get_optional('Firefox', 'binary')

        firefox_options = Options()

        if self.config.getboolean_optional('Driver', 'headless'):
            self.logger.debug("Running Firefox in headless mode")
            firefox_options.add_argument('-headless')

        self._add_firefox_arguments(firefox_options)

        if firefox_binary:
            firefox_options.binary = firefox_binary

        log_path = os.path.join(DriverWrappersPool.output_directory, 'geckodriver.log')
        try:
            # Selenium 3
            return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                     executable_path=gecko_driver, firefox_options=firefox_options, log_path=log_path)
        except TypeError:
            # Selenium 2
            return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                     executable_path=gecko_driver, firefox_options=firefox_options)
コード例 #5
0
ファイル: test_views.py プロジェクト: zhilangtaosha/tts-proxy
 def setUp(self):
     """ Setting up a fake browser """
     foxy_options = Options()
     foxy_options.headless = True
     foxy_options.binary = which('firefox')
     self.selenium = webdriver.Firefox(options=foxy_options)
     super().setUp()
コード例 #6
0
def main(name):
    binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'
    options = Options()
    options.set_headless(headless=True)
    options.binary = binary
    cap = DesiredCapabilities().FIREFOX
    cap["marionette"] = True  #optional
    driver = webdriver.Firefox(
        options=options,
        capabilities=cap,
        executable_path="C:\\Users\\Public\\geckodriver.exe")
    driver.implicitly_wait(10)
    driver.get("https://grandmaster.report/user/1/" + name)
    arr = []

    try:
        element = WebDriverWait(driver, 20).until(
            EC.presence_of_element_located(
                (By.CLASS_NAME, "UserActivity_cardContainer__2vOAf")))
        elements = driver.find_elements_by_class_name(
            "UserActivity_cardContainer__2vOAf")
        for el in elements:
            span = el.find_elements_by_tag_name("p")[1].text.replace('\n', ' ')
            print(span)
            arr.append(span)
    finally:
        driver.quit()
コード例 #7
0
    def _setup_firefox(self, capabilities):
        """Setup Firefox webdriver

        :param capabilities: capabilities object
        :returns: a new local Firefox driver
        """
        if capabilities.get("marionette"):
            gecko_driver = self.config.get('Driver', 'gecko_driver_path')
            self.logger.debug("Gecko driver path given in properties: %s", gecko_driver)
        else:
            gecko_driver = None

        # Get Firefox binary
        firefox_binary = self.config.get_optional('Firefox', 'binary')

        firefox_options = Options()

        if self.config.getboolean_optional('Driver', 'headless'):
            self.logger.debug("Running Firefox in headless mode")
            firefox_options.add_argument('-headless')

        self._add_firefox_arguments(firefox_options)

        if firefox_binary:
            firefox_options.binary = firefox_binary

        log_path = os.path.join(DriverWrappersPool.output_directory, 'geckodriver.log')
        try:
            # Selenium 3
            return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                     executable_path=gecko_driver, firefox_options=firefox_options, log_path=log_path)
        except TypeError:
            # Selenium 2
            return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                     executable_path=gecko_driver, firefox_options=firefox_options)
コード例 #8
0
def main(args):
    options = Options()
    options.headless = True
    options.binary = binary

    browser = webdriver.Firefox(options=options, executable_path=geckodriver)

    try:
        browser.get(address)
        login(browser)
        if args == '1':
            reboot(browser)
        elif args == '2':
            filter_mac(browser)
        elif args == '3':
            filter_mac(browser, True)
        else:
            print('Invalid argument: Use [1] to reboot, [2] to filter and [3] to reset')

    except Exception as e:
        print(e)

    finally:
        print('Exit Script')
        browser.quit()
コード例 #9
0
    def start(self, browser, url):

        if browser == "chrome":
            #global chromedriver
            chromedriver = webdriver.Chrome(executable_path="chromedriver.exe")
            chromedriver.maximize_window()
            chromedriver.get(url)
            self.chrome = chromedriver

            chrome_flag = True

            return "Chrome Browser Started............."

        elif browser == "firefox":
            binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'
            options = Options()
            options.binary = binary
            cap = DesiredCapabilities().FIREFOX
            cap["marionette"] = True
            firefoxdriver = webdriver.Firefox(
                firefox_options=options,
                capabilities=cap,
                executable_path="geckodriver.exe")

            firefoxdriver.maximize_window()
            firefoxdriver.get(url)
            self.firefox = firefoxdriver

            firefox_flag = True

            return "Firefox Browser Started............."

        else:

            return "Please enter the correct url"
コード例 #10
0
    def test_to_capabilities(self):
        opts = Options()
        assert opts.to_capabilities() == {}

        profile = FirefoxProfile()
        opts.profile = profile
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "profile" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["profile"], basestring)
        assert caps["moz:firefoxOptions"]["profile"] == profile.encoded

        opts.add_argument("--foo")
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "args" in caps["moz:firefoxOptions"]
        assert caps["moz:firefoxOptions"]["args"] == ["--foo"]

        binary = FirefoxBinary()
        opts.binary = binary
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "binary" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["binary"], basestring)
        assert caps["moz:firefoxOptions"]["binary"] == binary._start_cmd

        opts.set_preference("spam", "ham")
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "prefs" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["prefs"], dict)
        assert caps["moz:firefoxOptions"]["prefs"]["spam"] == "ham"
コード例 #11
0
    def test_to_capabilities(self):
        opts = Options()
        assert opts.to_capabilities() == {}

        profile = FirefoxProfile()
        opts.profile = profile
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "profile" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["profile"], types.StringTypes)
        assert caps["moz:firefoxOptions"]["profile"] == profile.encoded

        opts.add_argument("--foo")
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "args" in caps["moz:firefoxOptions"]
        assert caps["moz:firefoxOptions"]["args"] == ["--foo"]

        binary = FirefoxBinary()
        opts.binary = binary
        caps = opts.to_capabilities()
        assert "moz:firefoxOptions" in caps
        assert "binary" in caps["moz:firefoxOptions"]
        assert isinstance(caps["moz:firefoxOptions"]["binary"], types.StringTypes)
        assert caps["moz:firefoxOptions"]["binary"] == binary._start_cmd
コード例 #12
0
def get_firefox():
    binary = FirefoxBinary('/usr/bin/firefox')
    fp = webdriver.FirefoxProfile()
    fp.DEFAULT_PREFERENCES['frozen']['javascript.options.shared_memory'] = True
    fp.DEFAULT_PREFERENCES['frozen'][
        'javascript.options.wasm_baselinejit'] = False
    fp.DEFAULT_PREFERENCES['frozen']['javascript.options.wasm'] = True
    fp.DEFAULT_PREFERENCES['frozen']['javascript.options.wasm_ionjit'] = True
    fp.DEFAULT_PREFERENCES['frozen']['browser.tabs.remote.autostart'] = False
    fp.DEFAULT_PREFERENCES['frozen']['devtools.console.stdout.content'] = True
    options = FFOptions()
    fp.set_preference("browser.download.folderList", 2)
    fp.set_preference("browser.download.dir", "/mnt/homes/abhinav/Downloads")
    fp.set_preference("browser.download.useDownloadDir", True)
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk",
                      "application/x-tar")
    fp.add_extension('webconsoletap-1.0-fx.xpi')
    options.profile = fp
    options.binary = '/usr/bin/firefox'
    options.add_argument('-contentproc=2')
    d = DesiredCapabilities.FIREFOX
    d['loggingPrefs'] = {'browser': 'ALL'}
    options.set_capability(name='loggingPrefs', value={'browser': 'ALL'})
    return webdriver.Firefox(executable_path='/usr/bin/geckodriver',
                             firefox_options=options,
                             capabilities=d)
コード例 #13
0
ファイル: raids.py プロジェクト: HunBurry/SBD-Bots
def main(name):
    binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'
    options = Options()
    options.set_headless(headless=True)
    options.binary = binary
    cap = DesiredCapabilities().FIREFOX
    cap["marionette"] = True #optional
    driver = webdriver.Firefox(options=options, capabilities=cap, executable_path="C:\\Users\\Public\\geckodriver.exe")
    driver.implicitly_wait(10)
    driver.get("https://raid.report/xb/" + name)
    arr = [];

    try:
        element = WebDriverWait(driver, 20).until(
            EC.presence_of_element_located((By.CLASS_NAME, "total-completions"))
        )
        time.sleep(3)
        elements = driver.find_elements_by_class_name("total-completions")
        elements2 = driver.find_elements_by_class_name("s4")
        counter = 0;
        for el in elements:
            span = el.find_element_by_tag_name('span').text;
            arr.append(span);
            a = elements2[counter].find_elements_by_tag_name("a")
            if len(a) > 0:   
                arr.append(a[0].text);
            else:
                arr.append('N/A')
            counter = counter + 6;
    finally:
        driver.quit();
        for item in arr:
            print(item);
def getFirefoxWebdriver(proxy=None):
    profile = webdriver.FirefoxProfile()
    profile.set_preference("browser.newtabpage.enabled", False)
    profile.set_preference("browser.newtabpage.enhanced", False)
    profile.set_preference("browser.newtabpage.introShown", False)
    profile.set_preference("browser.newtabpage.directory.ping", "")
    profile.set_preference("browser.newtabpage.directory.source",
                           "data:application/json,{}")
    profile.set_preference("browser.newtab.preload", False)
    profile.set_preference("toolkit.telemetry.reportingpolicy.firstRun", False)
    profile.set_preference("http.response.timeout", 2)
    profile.set_preference("dom.max_script_run_time", 2)

    profile.set_preference("network.trr.mode", 2)
    profile.set_preference("network.trr.uri",
                           "https://mozilla.cloudflare-dns.com/dns-query")
    #profile.set_preference("network.trr.bootstrapAddress", "8.8.8.8")

    if proxy:
        profile.set_proxy(proxy.selenium_proxy())

    options = Options()
    options.binary = which("firefox")
    #options.add_argument("-headless")

    return webdriver.Firefox(firefox_profile=profile,
                             firefox_options=options,
                             log_path="/tmp/gecko.log")
コード例 #15
0
 def setUpClass(cls):
     super().setUpClass()
     firefox_options = Options()
     firefox_options.headless = True
     binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'
     firefox_options.binary = binary
     cls.selenium = webdriver.Firefox(firefox_options=firefox_options,
                                      executable_path="geckodriver.exe")
コード例 #16
0
ファイル: tests.py プロジェクト: matejt/tdd-book
    def create_browser(self):
        binary = r'C:\Users\dhdyk0\AppData\Local\Mozilla Firefox\firefox.exe'
        options = Options()
        options.binary = binary

        cap = DesiredCapabilities().FIREFOX
        cap["marionette"] = True

        return webdriver.Firefox(capabilities=cap, options=options)
コード例 #17
0
ファイル: selenium.py プロジェクト: mauza/seekout
def firefox_driver(binary: str, webdriver_path: str) -> webdriver:
    cap = DesiredCapabilities().FIREFOX
    cap["marionette"] = True
    options = Options()
    options.headless = True
    options.binary = binary
    return webdriver.Firefox(capabilities=cap,
                             options=options,
                             executable_path=webdriver_path)
コード例 #18
0
 def __init__(self, cookie_path: str = None) -> None:
     log.info("Creating firefox instance.")
     if settings.ads_block:
         firefox_profile = FirefoxProfile(
             settings.firefox_profile_rich_config)
     else:
         firefox_profile = FirefoxProfile(settings.firefox_profile_blank)
     # Disable cache to deal with overload issue when crawling lots of videos
     firefox_profile.set_preference("browser.cache.disk.enable", False)
     firefox_profile.set_preference("browser.cache.memory.enable", False)
     firefox_profile.set_preference("browser.cache.offline.enable", False)
     firefox_profile.set_preference("network.http.use-cache", False)
     log.info("Current firefox profile: {}".format(str(firefox_profile)))
     firefox_option = Options()
     firefox_option.headless = settings.headless
     firefox_option.binary = settings.firefox_binary_path
     log.info("Current firefox headless status: {}, binary path: {}".format(
         settings.headless, firefox_option.binary_location))
     self.browser: webdriver.Firefox = \
         webdriver.Firefox(firefox_profile=firefox_profile, options=firefox_option)
     self.browser.maximize_window()
     self.browser.delete_all_cookies()
     self.__COOKIE_LOAD_RETRY: int = 3
     self.__cookie_path: str = cookie_path
     if cookie_path and os.path.isfile(cookie_path):
         self.browser.get(settings.initial_website)
         time.sleep(5)
         log.info("Loading cookie from {}.".format(cookie_path))
         cookie_file = None
         while not cookie_file:
             try:
                 with open(cookie_path) as f:
                     cookie_file: List[str] = json.load(f)
             except Exception as e:
                 log.warning("Failed to read cookie file from {}.".format(
                     cookie_path))
                 self.__COOKIE_LOAD_RETRY -= 1
                 if self.__COOKIE_LOAD_RETRY <= 0:
                     raise
                 time.sleep(random.randint(1, 5))
         for cookie in cookie_file:
             try:
                 self.browser.add_cookie(cookie)
             except Exception as e:
                 if "youtube" not in repr(cookie).lower():
                     log.info(
                         "Failed to load cookie unrelated to YouTube {}. {}"
                         .format(cookie, e))
                 else:
                     log.error(
                         "Failed to load YouTube related cookie {}. {}.".
                         format(cookie, e),
                         exc_info=True)
     self.browser.get(settings.initial_website)
     log.info("Open initial website: {}".format(settings.initial_website))
     self.SHORT_WAIT = 5
     time.sleep(self.SHORT_WAIT)
コード例 #19
0
def getBrowser():
    binary = r'/usr/bin/firefox'
    cap = DesiredCapabilities().FIREFOX
    cap["marionette"] = True
    options = Options()
    options.headless = True
    options.binary = binary
    return webdriver.Firefox(capabilities=cap,
                             firefox_options=options,
                             executable_path=r'/usr/local/bin/geckodriver')
コード例 #20
0
 def setUpClass(cls):
     super().setUpClass()
     cap = DesiredCapabilities().FIREFOX
     cap["marionette"] = True
     binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'
     options = Options()
     options.set_headless(headless=True)
     options.binary = binary
     cls.driver = webdriver.Firefox(options=options, capabilities=cap)
     cls.driver.implicitly_wait(10)
コード例 #21
0
ファイル: baidu.py プロジェクト: xiekun1992/test_automation
 def setUp(self):
     # options = webdriver.ChromeOptions()
     # options.binary_location = 'G:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
     # self.driver = webdriver.Chrome('D:\\a_gitlab\\auto\\chromedriver.exe', chrome_options = options)
     options = Options()
     options.binary = r'C:\\Program Files\\Mozilla Firefox\\firefox.exe'
     cap = DesiredCapabilities().FIREFOX
     cap["marionette"] = True
     self.driver = webdriver.Firefox(
         firefox_options=options,
         capabilities=cap,
         executable_path="D:\\a_gitlab\\auto\\geckodriver.exe")
コード例 #22
0
 def setUp(self):
     binary = r"C:\Users\Juaco\AppData\Local\Mozilla Firefox\firefox.exe"
     options = Options()
     options.headless = True
     options.binary = binary
     cap = DesiredCapabilities().FIREFOX
     cap["marionette"] = True  # optional
     self.driver = webdriver.Firefox(
         options=options,
         capabilities=cap,
         executable_path="C:\\Users\\Juaco\\.pyenv\\pyenv-win\\versions\\3.7.3\\Scripts\\geckodriver.exe",
     )
コード例 #23
0
    def __setupdriver(self):
        options = Options()
        options.add_argument('--headless')
        options.add_argument('--no-sandbox')
        options.set_headless(headless=self.headless)

        cap = DesiredCapabilities().FIREFOX

        options.binary = self.firefoxpath

        self.driver = webdriver.Firefox(capabilities=cap,
                                        firefox_options=options,
                                        executable_path=self.geckopath)
コード例 #24
0
def create_instances_of_webdriver(selenium, driver, browser_id_list, tmpdir,
                                  tmp_memory, driver_kwargs, driver_type,
                                  firefox_logging, firefox_path, xvfb,
                                  screen_width, screen_height, displays):

    for browser_id, display in zip(parse_seq(browser_id_list), cycle(xvfb)):
        if browser_id in selenium:
            raise AttributeError('{:s} already in use'.format(browser_id))
        else:
            tmp_memory[browser_id] = {
                'shares': {},
                'spaces': {},
                'groups': {},
                'mailbox': {},
                'oz': {},
                'window': {
                    'modal': None
                }
            }

            with redirect_display(display):
                temp_dir = str(tmpdir)
                download_dir = os.path.join(temp_dir, browser_id, 'download')

                if driver_type.lower() == 'chrome':
                    option_keys = driver_kwargs['desired_capabilities'].keys()
                    option_key = [
                        x for x in option_keys if x.endswith('chromeOptions')
                    ][-1]
                    options = driver_kwargs['desired_capabilities'][option_key]

                    prefs = {"download.default_directory": download_dir}
                    options['prefs'].update(prefs)

                elif driver_type.lower() == 'firefox':
                    options = Options()
                    profile = FirefoxProfile()
                    log_path = _set_firefox_profile(profile, browser_id,
                                                    temp_dir, firefox_logging)
                    options.profile = profile
                    if firefox_path is not None:
                        options.binary = FirefoxBinary(firefox_path)
                    driver_kwargs['firefox_options'] = options

                browser = driver(driver_kwargs)
                if driver_type.lower() == 'firefox' and firefox_logging:
                    browser.get_log = _firefox_logger(log_path)
                _config_driver(browser, screen_width, screen_height)

            displays[browser_id] = display
            selenium[browser_id] = browser
コード例 #25
0
def loadBrowser(ffBinary, geckodriver, extensionPath):
    try:
        options = Options()
        # options.set_headless(headless=True)
        options.binary = ffBinary
        driver = webdriver.Firefox(
            options=options,
            executable_path=geckodriver,
        )
        driver.install_addon(extensionPath, temporary=True)
        return driver
    except Exception as err:
        logger.warning("Error starting FF driver: {0}".format(err))
        sys.exit(-1)
コード例 #26
0
    def setUp(self, firefox_bin):

        fp = webdriver.FirefoxProfile()

        fp.set_preference("browser.download.folderList", 2)
        fp.set_preference("browser.download.manager.showWhenStarting", False)
        fp.set_preference("browser.download.dir", "/tmp")
        fp.set_preference("browser.helperApps.neverAsk.saveToDisk",
                          "image/jpeg")
        firefox_options = Firefox_Options()
        firefox_options.binary = firefox_bin

        self.driver = webdriver.Firefox(firefox_profile=fp,
                                        options=firefox_options)
コード例 #27
0
def before_scenario(context, scenario):
    # context.browser = webdriver.Chrome('d:/Projects/Pets/chromedriver.exe')

    binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'

    options = Options()
    options.set_headless(headless=False)
    options.binary = binary
    cap = DesiredCapabilities().FIREFOX
    cap["marionette"] = True
    context.browser = webdriver.Firefox(firefox_options=options, capabilities=cap,
                                        executable_path=r'D:\Projects\Pets\geckodriver.exe')
    # Instances of Page Classes
    context.main_page = MainPage(context.browser)
    context.cart_page = CartPage(context.browser)
コード例 #28
0
 def __init__(self, username, password):
     self.username = username
     self.password = password
     cap = DesiredCapabilities().FIREFOX
     binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'
     options = Options()
     options.set_headless(headless=True)
     options.binary = binary
     cap["marionette"] = True
     self.bot = webdriver.Firefox(
         firefox_options=options,
         capabilities=cap,
         executable_path=
         r'C:\Users\shrey\OneDrive\Documents\geckodriver-v0.26.0-win64\geckodriver.exe'
     )
コード例 #29
0
    def setUp(self):
        binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'
        options = Options()
        options.set_headless(headless=True)
        options.binary = binary
        cap = DesiredCapabilities().FIREFOX
        cap["marionette"] = True

        self.driver = webdriver.Firefox(
            firefox_options=options,
            capabilities=cap,
            executable_path=
            "D:\\Programming\\Python_not_web\\QATESTLAB-TESTTASK-testing-automation2\\TestingAutomationQATESTLAB\\TestingAutomationQATESTLAB\\geckodriver.exe"
        )
        self.driver.get('http://booking.com')
コード例 #30
0
def getSeleniumDriverForFirefox(fireFoxBinaryPath, geckoDriverPath,
                                windowSizeXAxis, windowSizeYAxis):
    options = Options()
    options.set_headless(headless=True)
    options.binary = binary
    options.add_argument('--ignore-certificate-errors')

    cap = DesiredCapabilities().FIREFOX
    cap["marionette"] = True  #optional

    driver = webdriver.Firefox(firefox_options=options,
                               capabilities=cap,
                               executable_path=geckodriver)
    driver.set_window_size(
        windowSizeXAxis, windowSizeYAxis)  # set the window size that you need
    return driver
コード例 #31
0
def firefox_options(request, firefox_path, firefox_profile):
    options = Options()

    if firefox_profile is not None:
        options.profile = firefox_profile

    if firefox_path is not None:
        options.binary = FirefoxBinary(firefox_path)

    for arg in get_arguments_from_markers(request.node):
        options.add_argument(arg)

    for name, value in get_preferences_from_markers(request.node).items():
        options.set_preference(name, value)

    return options
コード例 #32
0
ファイル: browser_creation.py プロジェクト: indigo-dc/onedata
def create_instances_of_webdriver(selenium, driver, browser_id_list, tmpdir,
                                  tmp_memory, driver_kwargs, driver_type,
                                  firefox_logging, firefox_path, xvfb,
                                  screen_width, screen_height, displays):

    for browser_id, display in zip(parse_seq(browser_id_list), cycle(xvfb)):
        if browser_id in selenium:
            raise AttributeError('{:s} already in use'.format(browser_id))
        else:
            tmp_memory[browser_id] = {'shares': {},
                                      'spaces': {},
                                      'groups': {},
                                      'mailbox': {},
                                      'oz': {},
                                      'window': {'modal': None}}

            with redirect_display(display):
                temp_dir = str(tmpdir)
                download_dir = os.path.join(temp_dir, browser_id, 'download')

                if driver_type.lower() == 'chrome':
                    options = driver_kwargs['desired_capabilities']['chromeOptions']
                    prefs = {"download.default_directory": download_dir}
                    options['prefs'].update(prefs)

                elif driver_type.lower() == 'firefox':
                    options = Options()
                    profile = FirefoxProfile()
                    log_path = _set_firefox_profile(profile, browser_id,
                                                    temp_dir, firefox_logging)
                    options.profile = profile
                    if firefox_path is not None:
                        options.binary = FirefoxBinary(firefox_path)
                    driver_kwargs['firefox_options'] = options

                browser = driver(driver_kwargs)
                if driver_type.lower() == 'firefox' and firefox_logging:
                    browser.get_log = _firefox_logger(log_path)
                _config_driver(browser, screen_width, screen_height)

            displays[browser_id] = display
            selenium[browser_id] = browser
コード例 #33
0
ファイル: firefox.py プロジェクト: davehunt/pytest-selenium
def firefox_options(request, firefox_path, firefox_profile):
    options = Options()

    if firefox_profile is not None:
        options.profile = firefox_profile

    if firefox_path is not None:
        options.binary = FirefoxBinary(firefox_path)

    args = request.node.get_marker('firefox_arguments')
    if args is not None:
        for arg in args.args:
            options.add_argument(arg)

    prefs = request.node.get_marker('firefox_preferences')
    if prefs is not None:
        for name, value in prefs.args[0].items():
            options.set_preference(name, value)

    return options
コード例 #34
0
ファイル: config_driver.py プロジェクト: Telefonica/toolium
    def _setup_firefox(self, capabilities):
        """Setup Firefox webdriver

        :param capabilities: capabilities object
        :returns: a new local Firefox driver
        """
        if capabilities.get("marionette"):
            gecko_driver = self.config.get('Driver', 'gecko_driver_path')
            self.logger.debug("Gecko driver path given in properties: {0}".format(gecko_driver))
        else:
            gecko_driver = None

        # Get Firefox binary
        firefox_binary = self.config.get_optional('Firefox', 'binary')
        if firefox_binary:
            self.logger.debug("Using firefox binary: {0}".format(firefox_binary))
            firefox_options = Options()
            firefox_options.binary = firefox_binary
        else:
            firefox_options = None

        return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                 executable_path=gecko_driver, firefox_options=firefox_options)