How to use the selenium.webdriver.Firefox function in selenium

To help you get started, we’ve selected a few selenium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IQSS / dataverse / tests / test_access.py View on Github external
def setUp(self):
        if (config.local):
            self.wd = webdriver.Firefox()
        else:
            desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
            desired_capabilities['version'] = '24'
            desired_capabilities['platform'] = 'Linux'
            desired_capabilities['name'] = 'test_access'
            self.wd = webdriver.Remote(
                desired_capabilities=desired_capabilities,
                command_executor="http://esodvn:325caef9-81dd-47a5-8b74-433057ce888f@ondemand.saucelabs.com:80/wd/hub"
            )
 
        self.wd.implicitly_wait(60)
github nicksergeant / billmonster / bankofamerica.py View on Github external
# Get the user's password from the password backend.
    key = keyring.get_password('bankofamerica.com', user)

    # If the key doesn't exist in the password backend.
    if key is None:
        puts(colored.red("You must store the password for {} in your keyring's backend.".format(user)))
        puts('See: http://pypi.python.org/pypi/keyring/#configure-your-keyring-lib')
        sys.exit()

    # Log what we're currently working on.
    puts(colored.blue('\nBank of America ({})'.format(user)))

    if not browser:
        # Init the WebDriver.
        b = webdriver.Firefox()
    else:
        b = browser

    b.get('https://www.bankofamerica.com/')

    # Find the username field on the page.
    username = b.find_element_by_css_selector('input#id')
    username.send_keys(user)

    # Get the state out of the user's config.
    state_config = config._sections['bankofamerica']['state']

    # Select the correct state.
    state = b.find_element_by_css_selector('option[value="{}"]'.format(state_config))
    state.click()
github lino-framework / lino / lino / api / selenium.py View on Github external
def runserver(settings_module, func, driver=None):

    if driver is None:
        driver = webdriver.Firefox() # service_log_path=os.path.devnull)
        # driver = webdriver.Chrome('/usr/bin/chromium-browser')

    if INVOKE_SERVER:
        env = dict()
        if False:
            env.update(LINO_BUILD_CACHE_ON_STARTUP='yes')
        env.update(os.environ)
        args = ['django-admin', 'runserver', '--noreload', '--settings',
                settings_module]
        server = subprocess.Popen(args, stdout=None, stderr=None, env=env)

        # driver.implicitly_wait(10) # seconds
        # time.sleep(10)
        # startup_time = 1
        # print("Sleeping {} seconds while server wakes up...".format(startup_time))
        # time.sleep(startup_time)
github preetchaahal / python-chaturbate-bot / proxies_scrape.py View on Github external
def init_browser(self, type='firefox', options={'headless': False, 'maximize_window': True}, proxy_obj=False):
		## Initialize Firefox browser
		no_options = True
		if options['headless']:
			options = Options()
			options.add_argument('-headless')
			no_options = False
		if proxy_obj == False:
			browser = webdriver.Firefox()
			self.browser = browser
		else:
			profile = self.set_proxy_profile(proxy_obj['ip'], proxy_obj['port'])
			# print(profile)
			if no_options:
				browser = webdriver.Firefox(firefox_profile = profile)
			else:
				browser = webdriver.Firefox(firefox_profile = profile, options=options)
			self.browser = browser
		browser.maximize_window()
		return browser
github diegocavalca / machine-learning / applications / scraping / download-certidoes.py View on Github external
#fp.accept_untrusted_certs = True
        fp.set_preference("browser.download.folderList",2)
        fp.set_preference("browser.download.dir", "/path_to_downloads_folder/")
        fp.set_preference("browser.helperApps.alwaysAsk.force", False)
        fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/pdf,application/csv,application/excel,application/vnd.msexcel,application/vnd.ms-excel,text/anytext,text/comma-separated-values,text/csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/octet-stream")
        fp.set_preference("browser.helperApps.neverAsk.openFile","application/pdf,application/csv,application/excel,application/vnd.msexcel,application/vnd.ms-excel,text/anytext,text/comma-separated-values,text/csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/octet-stream")
        fp.set_preference("browser.download.manager.showWhenStarting", False)
        fp.set_preference("browser.download.manager.useWindow", False)
        fp.set_preference("browser.download.manager.focusWhenStarting", False)
        fp.set_preference("browser.download.manager.alertOnEXEOpen", False)
        fp.set_preference("browser.download.manager.showAlertOnComplete", False)
        fp.set_preference("browser.download.manager.closeWhenDone", True)
        fp.set_preference("pdfjs.disabled", True)
        fp.set_preference('browser.download.panel.shown', False)
        fp.set_preference('pdfjs.enabledCache.state', False)
        driver = webdriver.Firefox(firefox_options=opts, firefox_profile=fp)

    elif optDriver.lower() == 'chrome':

        # https://blog.softhints.com/ubuntu-16-04-server-install-headless-google-chrome/
        options = webdriver.ChromeOptions() 
        options.add_argument("download.default_directory=/path_to_downloads_folder/")
        options.add_argument("download.prompt_for_download=False")
        options.add_argument("download.directory_upgrade=True")
        options.add_argument("safebrowsing.enabled=True")
        options.add_argument('--ignore-certificate-errors')
        options.add_argument("--headless")
        options.add_argument("window-size="+str(screenW)+","+str(screenH)+"")
        options.add_argument("--no-sandbox")
        driver = webdriver.Chrome(chrome_options=options, executable_path='/usr/local/bin/chromedriver')

    else:
github Kodi-vStream / venom-xbmc-addons / plugin.video.vstream / resources / sites / tirexo.py View on Github external
options = Options()
        
        #options.add_argument("headless")
        #options.add_argument("window-size=1920,1080")
        options.add_argument("'user-agent={}".format(UA))
        #options.add_argument("disable-gpu")
        
        capabilities = DesiredCapabilities.CHROME.copy()
        capabilities['acceptSslCerts'] = True 
        capabilities['acceptInsecureCerts'] = True

        browser = webdriver.Chrome(driverPath, options=options,desired_capabilities=capabilities)
    else:
        path = r"C:\Users\XXXX\AppData\Roaming\Kodi\addons\script.module.selenium\bin\geckodriver\win32\geckodriver\geckodriver.exe"
        #path sert pour firefox
        browser = webdriver.Firefox(executable_path=path, options=options, log_path="")
    
    browser.get(url)
    
    #On boucle si Cloudflare n'est pas résolu.
    #On loop que 3 fois maxi.
    loop = 0
    while CloudflarePassed == False:
        if loop > 3:
            break
        
        #On se sert du cookie pour voir si Cloudflare est résolu
        Cookies = browser.get_cookies()
        if "cf_clearance" in str(Cookies):
            break
        
        #Si pas de protection CF
github kudeh / automate-the-boring-stuff-projects / command-line-email / yahoomail-emailer.py View on Github external
emailRegex = re.compile(r'''(
        [a-zA-Z0-9._%+-]+      # username
        @                      # @ symbol
        [a-zA-Z0-9.-]+         # domain name
        (\.[a-zA-Z]{2,4})      # dot-something
        )''', re.VERBOSE)  

    if not emailRegex.match(sendTo):
        print("**Invalid Email Address Provided**")

    else:

        delay = 10 # seconds

        # Set up selenium browser
        browser = webdriver.Firefox(executable_path='/Users/keneudeh/Downloads/geckodriver')
        browser.get('https://login.yahoo.com')

        # Enter yahoo email address
        loginUsernameElem = browser.find_element_by_id('login-username')
        loginUsernameElem.send_keys(sendFrom)
        loginUsernameElem.send_keys(Keys.TAB)
        
        # Press 'Next' to go to password filed page
        nextBtnElem = browser.find_element_by_id('login-signin')
        nextBtnElem.send_keys(Keys.ENTER)

        # Wait for 'password' field page to load then enter password, tab to submit btn
        loginPwdElem = wait_for_page_load(browser, By.ID, 'login-passwd', delay)
        loginPwdElem.send_keys(password)
        loginPwdElem.send_keys(Keys.TAB)
github xbwei / Data-Mining-on-Social-Media / Other / Get_Job_from_Web.py View on Github external
def scrape_url(url):
    '''
    get job info  from scrolling page
    '''
 
    # Load WebDriver and navigate to the page url.
    # This will open a browser window.
    driver = webdriver.Firefox()



    driver.get(url)

    try:
#         while ('No results' not in driver.find_element_by_class_name('empty-text').text):
        for i in range(0,50):
    
                                           
                                           
            elem = driver.find_element_by_tag_name('li')
            elem.send_keys(Keys.PAGE_DOWN)
         
        # Once the whole table has loaded, grab all the visible links.    
        visible_links = driver.find_elements_by_tag_name('li')
github microsoft / TextWorld / textworld / utils.py View on Github external
def firefox_driver(path=None):
        from selenium.webdriver.firefox.options import Options
        options = Options()
        options.add_argument('headless')
        driver = webdriver.Firefox(firefox_binary=path, options=options)
        return driver
github azerpas / nike_Raffle_FR / main2.py View on Github external
#{"url":"product/nike-zoom-vaporfly/","shoe_id":"9","shoe_name":"Nike Zoom Vaporfly","imgURL":"ZoomVaporfly.jpg"},
		#{"url":"product/nike-vapor-max/","shoe_id":"10","shoe_name":"Nike Vapormax","imgURL":"Vapormax.jpg"},
		#{"url":"product/nike-force-1-low/","shoe_id":"11","shoe_name":"Nike Air Force 1 Low","imgURL":"AirForce1.jpg"},
		#{"url":"product/product/nike-air-max-97/","shoe_id":"12","shoe_name":"Nike Air Max 97","imgURL":"AirMax97.jpg"},
		{"url":"product/air-jordan-1-white/","shoe_id":"14","shoe_name":"The Ten: Air Jordan 1","imgURL":"AirJordan@100cropped.jpg"},
		]
		self.count = 0 
		self.sites = [
			#{"url":"https://shinzo.sneakers-raffle.fr/","siteid":"2","nomtemplate":"nike-raffle-confirm-shinzo"},
			#{"url":"https://thebrokenarm.sneakers-raffle.fr/","siteid":"3","nomtemplate":"nike-raffle-confirm-the-broken-arm"},
			#{"url":"https://colette.sneakers-raffle.fr/","siteid":"4","nomtemplate":"nike-raffle-confirm-colette"},
			#{"url":"https://starcow.sneakers-raffle.fr/","siteid":"5","nomtemplate":"nike-raffle-confirm-starcow"}
			{"url":"https://off---white.sneakers-raffle.fr/","siteid":"8","nomtemplate":"nike-raffle-confirm-off---white"}
			]
		self.api = "https://api.sneakers-raffle.fr/submit"
		self.driver = webdriver.Firefox() #webdriver.Chrome()  #service_args
		# interval etc