Ejemplo n.º 1
0
 def get_mozilla_browser(self):
     options = FirefoxOptions()
     options.add_argument("no-sandbox")
     options.accept_untrusted_certs = True
     options.assume_untrusted_cert_issuer = True
     options.add_argument("--disable-infobars")
     options.add_argument("--headless")
     driver_ = webdriver.Firefox(executable_path=GeckoDriverManager().install(), options=options)
     return driver_
def init_chrome_driver(request):
    if request.param == 'chrome':
        driver = webdriver.Chrome(ChromeDriverManager().install())
    if request.param == 'firefox':
        driver = webdriver.Firefox(
            executable_path=GeckoDriverManager().install())
    request.cls.driver = driver
    yield
    driver.close()
Ejemplo n.º 3
0
 def create_driver(self, remote_host, capabilities):
     options = webdriver.FirefoxOptions()
     if remote_host is None:
         return webdriver.Firefox(executable_path=GeckoDriverManager().install(),
                         options=options,
                         desired_capabilities=capabilities)
     else:
         return webdriver.Remote(command_executor=remote_host,
                             desired_capabilities=options.to_capabilities())
Ejemplo n.º 4
0
def driver_firefox():
    # Configurações para execução.
    firefox_options = Options()
    firefox_options.headless = True
    # Inicializa o webdriver.
    driver = webdriver.Firefox(options=firefox_options,
                               executable_path=GeckoDriverManager().install())

    return driver
Ejemplo n.º 5
0
 def __init__(self):
     firefox_capabilities = DesiredCapabilities.FIREFOX.copy()
     firefox_capabilities["acceptSslCerts"] = True
     super().__init__(name="Firefox",
                      webdriver_class=webdriver.Firefox,
                      webdriver_manager=GeckoDriverManager(),
                      desired_capabilities=firefox_capabilities,
                      firefox_profile=FirefoxProfile()
                      )
Ejemplo n.º 6
0
def change_browser(request):
    browser_name = request.config.getoption("--browser")
    if browser_name == "chrome":
        br = webdriver.Chrome(ChromeDriverManager().install())
    elif browser_name == "firefox":
        br = webdriver.Firefox(executable_path=GeckoDriverManager().install())
    else:
        raise ValueError("Unrecognized browser {}".format(browser_name))
    return br
Ejemplo n.º 7
0
def setup(browser):
    if browser == 'chrome':
        driver = webdriver.Chrome(ChromeDriverManager().install())
        print("Launching chrome browser.........")
    elif browser == 'firefox':
        driver = webdriver.Firefox(
            executable_path=GeckoDriverManager().install())
        print("Launching firefox browser.........")
    return driver
Ejemplo n.º 8
0
 def getBrowser(browser='chrome'):
     path = f'ILCourtScraper{sep}WebDrivers{sep}'
     if browser == 'chrome':
         return webdriver.Chrome(ChromeDriverManager().install())
     elif browser == 'firefox':
         return webdriver.Firefox(GeckoDriverManager().install())
     elif browser == 'edge':
         if system() == 'Windows':
             return webdriver.Edge(executable_path=getPath(N=0) + path + 'msedgedriver.exe')
def start_browser():

    global driver
    driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
    driver.maximize_window()
    global wait
    wait = WebDriverWait(driver, 20)
    yield
    driver.quit()
Ejemplo n.º 10
0
def get_driver_path(browser):
    driver_path = ""
    if browser == "chrome":
        driver_path = ChromeDriverManager().install()
    elif browser == "firefox":
        driver_path = GeckoDriverManager().install()
    else:
        print("Incorrect Browser")
    return driver_path
Ejemplo n.º 11
0
 def __init__(self):
     # accessing the page holding comments (here: youtube)
     # self.driver = webdriver.Chrome(ChromeDriverManager().install())
     self.driver = webdriver.Firefox(
         executable_path=GeckoDriverManager().install())
     self.scroll_pause_sec = 2
     self.num_cycles = 7
     self.max_find_elem_attempts = 3
     self.base_url = "https://www.youtube.com"
Ejemplo n.º 12
0
    def setUp(self):
        #initialise firefox options
        options = FirefoxOptions()
        #add cookies on driver
        options.add_argument("user-data-dir=selenium")
        #initialise driver
        driver = webdriver.Firefox(executable_path=GeckoDriverManager().install(), firefox_options=options)

        self.jobSearch = JobSearch(linkedin_url="https://www.linkedin.com/jobs/", job_title="Software developer", location="United Kingdom", driver=driver)
Ejemplo n.º 13
0
 def __init__(self, _client_key, _headless):
     self.options = Options()
     self.options.headless = _headless
     self.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"
     self.captcha = RecaptchaV2Task(_client_key)
     self.browser = webdriver.Firefox(service=Service(
         GeckoDriverManager().install()),
                                      options=self.options)
     self.website_url = "https://www.google.com/recaptcha/api2/demo"
Ejemplo n.º 14
0
    def initialize(self, browserType):
        global driver
        if browserType == "firefox":
            driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

        if browserType == "chrome":
            driver = webdriver.Chrome(executable_path=ChromeDriverManager().install())

        return driver
Ejemplo n.º 15
0
def create_driver():
    global profile_path
    profile_path = get_profile_path()
    default_profile = get_default_profile(profile_path)
    print(f'Launching Firefox using default profile: {default_profile}')
    profile = prepare_sniper_profile(profile_path / default_profile)
    driver = webdriver.Firefox(firefox_profile=profile,
                               executable_path=GeckoDriverManager().install())
    return driver
Ejemplo n.º 16
0
def get_driver(request):
    driver: WebDriver = webdriver.Firefox(
        executable_path=GeckoDriverManager().install())
    driver.maximize_window()
    driver.get("http://pharmacy-test-preprod.newmedicine.com.ua/")
    request.cls.driver = driver
    yield
    driver.close()
    driver.quit()
Ejemplo n.º 17
0
def __start_firefox(name):
    executable_path = "wires"
    if name == BrowserName.MARIONETTE:
        executable_path = GeckoDriverManager().install()
    driver = webdriver.Firefox(capabilities=config.desired_capabilities,
                               executable_path=executable_path)
    if config.start_maximized:
        driver.maximize_window()
    return driver
def init__driver(request):
    if request.param == "chrome":
        web_driver = webdriver.Chrome(ChromeDriverManager().install())
    if request.param == "firefox":
        web_driver = webdriver.Firefox(
            executable_path=GeckoDriverManager().install())
    request.cls.driver = web_driver
    yield
    web_driver.close()
Ejemplo n.º 19
0
 def open_firefox(self):
     from webdriver_manager.firefox import GeckoDriverManager
     caps = DesiredCapabilities().FIREFOX
     caps["pageLoadStrategy"] = "normal"  # complete
     # caps["pageLoadStrategy"] = "eager"  #  interactive
     # caps["pageLoadStrategy"] = "none"
     self.driver = webdriver.Firefox(
         desired_capabilities=caps,
         executable_path=GeckoDriverManager().localDependency())
Ejemplo n.º 20
0
def main() -> None:
    browser = webdriver.Firefox(executable_path=GeckoDriverManager().install())
    browser.get("https://techstepacademy.com/trial-of-the-stones")

    answer_stones_riddle(browser)
    answer_secrets_riddle(browser)
    answer_richest_merchant(browser)

    browser.close()
Ejemplo n.º 21
0
 def get_driver():
     BROWSER = os.getenv('BROWSER', 'chrome')
     driver = None
     operation_system = platform.system()
     arch = platform.architecture()
     if BROWSER == 'chrome':
         options = Options()
         if os.getenv('HEADLESS', 'false').lower() == 'true':
             options.headless = True
         options.add_argument("--no-sandbox")
         options.add_argument("--disable-dev-shm-usage")
         options.add_argument("--incognito")
         options.add_argument("--window-size=1920,1080")
         options.add_experimental_option('w3c', False)
         try:
             driver = webdriver.Chrome(ChromeDriverManager().install(),
                                       options=options)
         except:
             gevent.sleep(2)
             driver = webdriver.Chrome(ChromeDriverManager().install(),
                                       options=options)
     elif BROWSER == 'firefox':
         if operation_system == "Darwin" or "Linux":
             driver = webdriver.Firefox(
                 executable_path=GeckoDriverManager().install())
         else:
             if arch[0] == "32bit":
                 driver = webdriver.Firefox(
                     executable_path=GeckoDriverManager(
                         os_type="win32").install())
             elif arch[0] == "64bit":
                 driver = webdriver.Firefox(
                     executable_path=GeckoDriverManager(
                         os_type="win64").install())
     elif BROWSER == 'safari':
         driver = webdriver.Safari(executable_path='/usr/bin/safaridriver')
     elif BROWSER == 'ie':
         if arch[0] == "32bit":
             driver = webdriver.Ie(executable_path=IEDriverManager(
                 os_type="Win32").install())
         elif arch[0] == "64bit":
             driver = webdriver.Ie(executable_path=IEDriverManager(
                 os_type="x64").install())
     return Driver.add_driver_settings(driver)
Ejemplo n.º 22
0
def parse_page(stock, *args, **kw):
    # If args is not set then I am returning the historical data using the builin method
    if not args:
        return wb.DataReader(stock, **kw)
   
    # Otherwise I am parsing a page from the internet
    else:
        url, attrs = args
        key = kw.get('key')
        # If kw is empty that means we only want to parse the summary page
        if not kw:
            # There are no buttons I need to press on this page so no need for selenium
            page = requests.get(url + stock + attrs['stock_key'] + stock)
            return parse_by_table(page)
        # If key is not None then we need to parse a specific financial page
        if key:
            page = requests.get(url + stock + '/' + key + attrs['stock_key'] + stock)
            # I first try to parse the page using the <table> element
            # If the page doesn't have a table then the function will return
            # A ValueError exception
            try:
                data = parse_by_table(page, singular=True)
            except ValueError:
                '''
                    THERE IS STILL A PROBLEM HERE WITH THE SELENIUM OBJECT. IDK
                '''
                driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
                driver.get(url + stock + '/' + key + attrs['stock_key'] + stock)
                table = driver.find_element_by_xpath('//*[@id="Col1-1-Financials-Proxy"]/section/div[4]/div[1]/div[1]/div[2]')
                click_buttons(table)
                soup = BeautifulSoup(driver.page_source, 'html.parser')
                data = parse_by_attributes(soup, 
                                      tabl_info={BeautifulSoup.find : ('div', {'class' : 'D(tbr)'})},
                                           tabl={BeautifulSoup.find : ('div', {'class' : 'D(tbrg)'})},
                                           cols={BeautifulSoup.find_all : {'tabl_info' : ('div' , {'class' : 'Ta(c)'})}},
                                           rows={BeautifulSoup.find_all : {'tabl'      : ('span', {'class' : 'Va(m)'})}},
                                           data={BeautifulSoup.find_all : {'tabl'      : ('div' , {'data-test' : 'fin-col'})}})
                                      
                driver.close()
            
            return data
        
        # If nothing else has returned this function then we are getting the current price
        # This will run interval amount of times, sleeping frequency seconds each time
        else:
            data = pd.DataFrame()
            for i in range(kw.get('interval')):
                page = requests.get(url + stock + attrs['stock_key'] + stock)
                soup = BeautifulSoup(page.content, 'html.parser')
                # You have to pass stock here as a 3D list
                data = data.append(parse_by_attributes(soup,
                                       cols=[[[stock]]], 
                                       rows={BeautifulSoup.find : {'soup' : ('span', {'data-reactid' : '53'})}},
                                       data={BeautifulSoup.find : {'soup' : ('span', {'data-reactid' : '50'})}}))
                sleep(kw.get('frequency'))
            return data
Ejemplo n.º 23
0
 def get_driver(browser):
     if browser == 'chrome':
         options = webdriver.ChromeOptions()
         options.add_argument('start-maximized')
         return webdriver.Chrome(ChromeDriverManager().install(), options=options)
     elif browser == 'firefox':
         options = webdriver.FirefoxOptions()
         options.add_argument('start-maximized')
         return webdriver.Firefox(executable_path=GeckoDriverManager().install(), options=options)
     raise Exception('Provide valid driver name')
Ejemplo n.º 24
0
 def __init__(self, _client_key, _headless):
     self.options = Options()
     self.options.headless = _headless
     self.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"
     self.captcha = FuncaptchaTask(_client_key)
     self.browser = webdriver.Firefox(service=Service(
         GeckoDriverManager().install()),
                                      options=self.options)
     self.website_url = "https://client-demo.arkoselabs.com/solo-animals"
     self.expected = "Solved!"
Ejemplo n.º 25
0
def init_driver(request):
    if request.param == "chrome":
        web_driver = webdriver.Chrome(
            executable_path=TestData.CHROME_EXECUTABLE_PATH)
    if request.param == "firefox":
        web_driver = webdriver.Firefox(
            executable_path=GeckoDriverManager().install())
    request.cls.driver = web_driver
    yield
    web_driver.close()
 def test_clickOrGetText_From_tableTD(self):
     driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
     driver.maximize_window()
     driver.get("https://www.w3schools.com/html/html_tables.asp")
     driver.execute_script("window.scrollBy(0,300)")
     tableDatas = driver.find_elements_by_xpath("//*[@id='customers']/tbody/tr/td")
     for i in range(len(tableDatas)):
         #print(i, tableDatas[i].text) # will print all the TD text from Table
         if tableDatas[i].text == "Island Trading":
             print(tableDatas[i+1].text)
Ejemplo n.º 27
0
def init_driver(request,browser):
    if request.param == 'chrome' and browser == 'chrome':
        driver = webdriver.Chrome(ChromeDriverManager().install())
    elif request.param == 'chrome' and browser == 'firefox':
        driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
    else:
        driver = webdriver.Chrome(ChromeDriverManager().install()) #By default Chrome
    request.cls.driver = driver  #Making driver instance available to the complete class
    yield
    driver.close()
Ejemplo n.º 28
0
def start_firefox(binary_path):
    from webdriver_manager.firefox import GeckoDriverManager
    from selenium.webdriver.firefox.options import Options

    options = Options()
    options.set_headless()

    if binary_path: options.binary_location = binary_path

    return webdriver.Firefox(GeckoDriverManager().install(), options=options)
 def __init__(self, _client_key, _headless):
     self.options = Options()
     self.options.headless = _headless
     self.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"
     self.captcha = HCaptchaTask(_client_key)
     self.browser = webdriver.Firefox(service=Service(
         GeckoDriverManager().install()),
                                      options=self.options)
     self.website_url = "http://hcaptcha.jawne.info.pl/"
     self.expected = "Your request have submitted successfully"
Ejemplo n.º 30
0
def init_firefox_driver(request):
    print('------------This is my setup---------------')
    ff_driver = webdriver.Firefox(
        executable_path=GeckoDriverManager().install())
    #Instead of defining global driver, create a request parameter
    request.cls.driver = ff_driver

    yield
    print('------------This is my teardown----------------')
    ff_driver.close()