Python selenium.webdriver.Firefox() Examples
The following are 30
code examples of selenium.webdriver.Firefox().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
selenium.webdriver
, or try the search function
.
Example #1
Source File: ris.py From uncaptcha with MIT License | 11 votes |
def start_captcha(): driver = webdriver.Firefox() driver.get("http://reddit.com") driver.find_element(By.XPATH, "//*[@id=\"header-bottom-right\"]/span[1]/a").click() time.sleep(1) driver.find_element(By.ID, "user_reg").send_keys("qwertyuiop091231") driver.find_element(By.ID, "passwd_reg").send_keys("THISISMYPASSWORD!!$") driver.find_element(By.ID, "passwd2_reg").send_keys("THISISMYPASSWORD!!$") driver.find_element(By.ID, "email_reg").send_keys("biggie.smalls123@gmail.com") #driver.find_element_by_tag_name("body").send_keys(Keys.COMMAND + Keys.ALT + 'k') iframeSwitch = driver.find_element(By.XPATH, "//*[@id=\"register-form\"]/div[6]/div/div/div/iframe") driver.switch_to.frame(iframeSwitch) driver.find_element(By.ID, "recaptcha-anchor").click() # download captcha image # # split payload # # reverse_search # # driver.quit() # determines if an image keywords matches the target keyword # uses the synonyms of the image keyword
Example #2
Source File: test_get_proxy.py From wanggeService with MIT License | 10 votes |
def test_webdriver2(self): import time from selenium import webdriver # myProxy = "127.0.0.1:9150" myProxy = "192.168.103.1:1081" ip, port = myProxy.split(":") fp = webdriver.FirefoxProfile() fp.set_preference('network.proxy.type', 1) fp.set_preference('network.proxy.socks', ip) fp.set_preference('network.proxy.socks_port', int(port)) driver = webdriver.Firefox(fp) url = 'https://api.ipify.org' # url = "http://data.eastmoney.com/hsgtcg/StockHdDetail.aspx?stock=600519&date=2018-06-12/" driver.get(url) # print(driver.find_element_by_tag_name('table').text) print(driver.find_element_by_tag_name('pre').text) driver.get('https://check.torproject.org/') time.sleep(3) driver.quit()
Example #3
Source File: test_website.py From bepasty-server with BSD 2-Clause "Simplified" License | 7 votes |
def setup_class(self): """ Setup: Open a mozilla browser, login """ self.browser = Firefox() self.browser.get('http://localhost:5000/') token = self.browser.find_element_by_name("token") password = "foo" # login token.send_keys(password) token.send_keys(Keys.ENTER) time.sleep(.1) try: self.browser.find_element_by_xpath("//input[@value='Logout']") except NoSuchElementException: raise ValueError("Can't login!!! Create a user 'foo' with the permissions" "'read' and 'create' in your PERMISSIONS in the config")
Example #4
Source File: tools.py From JobFunnel with MIT License | 6 votes |
def get_webdriver(): """Get whatever webdriver is availiable in the system. webdriver_manager and selenium are currently being used for this. Supported browsers:[Firefox, Chrome, Opera, Microsoft Edge, Internet Expolorer] Returns: a webdriver that can be used for scraping. Returns None if we don't find a supported webdriver. """ try: driver = webdriver.Firefox( executable_path=GeckoDriverManager().install()) except Exception: try: driver = webdriver.Chrome(ChromeDriverManager().install()) except Exception: try: driver = webdriver.Ie(IEDriverManager().install()) except Exception: try: driver = webdriver.Opera( executable_path=OperaDriverManager().install()) except Exception: try: driver = webdriver.Edge( EdgeChromiumDriverManager().install()) except Exception: driver = None logging.error( "Your browser is not supported. Must have one of the following installed to scrape: [Firefox, Chrome, Opera, Microsoft Edge, Internet Expolorer]") return driver
Example #5
Source File: main.py From SneakerBotTutorials with MIT License | 6 votes |
def createHeadlessBrowser(proxy=None, XResolution=1024, YResolution=768, timeout=20): #proxy = None if TEST_MODE == False: dcap = dict(DesiredCapabilities.PHANTOMJS) dcap["phantomjs.page.settings.userAgent"] = ( 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.86 Safari/537.36') # Fake browser headers if proxy != None: # This means the user set a proxy service_args = ['--proxy={}'.format(proxy),'--proxy-type=https','--ignore-ssl-errors=true', '--ssl-protocol=any', '--web-security=false',] driver = webdriver.PhantomJS(service_args=service_args, desired_capabilities=dcap) else: # No proxy was set by the user driver = webdriver.PhantomJS(desired_capabilities=dcap) driver.set_window_size(XResolution,YResolution) # Sets the screen resolution # Ideally this will be dynamic based on the number of browsers open driver.set_page_load_timeout(timeout) # Sets the timeout for the selenium window else: driver = webdriver.Firefox() return driver # Returns driver instance
Example #6
Source File: main.py From SneakerBotTutorials with MIT License | 6 votes |
def convertHeadless(driver, url): #converts a phantomjs browser to a firefox webdriver window cookies = driver.get_cookies() #saves cookies as dict driver.quit() #closes the phantomjs window driver = webdriver.Firefox() #replaces phantomjs instance with firefox browser driver.get(url) # has to go to the url before adding cookies # If you were doing this with shoes - it should show an empty cart for cookie in cookies: #adds cookies to the driver driver.add_cookie(cookie) driver.get(url) # this will reload the url with the cookies you imported return driver
Example #7
Source File: browser.py From QRLJacking with GNU General Public License v3.0 | 6 votes |
def load_cookie(self, session_id): sessions = json.load(open( self.sessions_file )) cookie_path = sessions[str(session_id)]["session_path"] url = sessions[str(session_id)]["web_url"] # Setting useragent to the same one the session saved with useragent = sessions[str(session_id)]["useragent"] profile = FirefoxProfile() profile.set_preference("general.useragent.override", useragent ) cookies = pickle.load(open(cookie_path, "rb")) try: browser = Firefox(profile) except: error("Couldn't open browser to view session!") return browser.get(url) browser.delete_all_cookies() browser.execute_script("window.localStorage.clear()") # clear the current localStorage for cookie in cookies: browser.add_cookie(cookie) status(f"Session {session_id} loaded") browser.refresh() self.browsers.append(browser)
Example #8
Source File: config.py From EagleEye with Do What The F*ck You Want To Public License | 6 votes |
def getWebDriver(): if not os.path.isfile(cfg['WEBDRIVER']['PATH']): print("{0} does not exist - install a webdriver".format(cfg['WEBDRIVER']['PATH'])) sys.exit(-2) d = cfg['WEBDRIVER']['ENGINE'] if d.lower() == 'firefox': os.environ["webdriver.firefox.driver"] = cfg['WEBDRIVER']['PATH'] p = os.path.join(tempfile.gettempdir(), 'imageraider') if not os.path.isdir(p): os.makedirs(p) profile = webdriver.FirefoxProfile() profile.set_preference('browser.download.folderList', 2) # custom location profile.set_preference('browser.download.manager.showWhenStarting', False) profile.set_preference('browser.download.dir', p) profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv') profile.set_preference("browser.link.open_newwindow", 3) profile.set_preference("browser.link.open_newwindow.restriction", 2) return webdriver.Firefox(profile) else: os.environ["webdriver.chrome.driver"] = cfg['WEBDRIVER']['PATH'] return webdriver.Chrome()
Example #9
Source File: amazon_bot.py From youtube_tutorials with GNU General Public License v3.0 | 6 votes |
def __init__(self, items): """Setup bot for Amazon URL.""" self.amazon_url = "https://www.amazon.ca/" self.items = items self.profile = webdriver.FirefoxProfile() self.options = Options() #self.options.add_argument("--headless") self.driver = webdriver.Firefox(firefox_profile=self.profile, firefox_options=self.options) # Navigate to the Amazon URL. self.driver.get(self.amazon_url) # Obtain the source self.html = self.driver.page_source self.soup = BeautifulSoup(self.html, 'html.parser') self.html = self.soup.prettify('utf-8')
Example #10
Source File: accounts.py From twitter-accounts-creator-bot with MIT License | 6 votes |
def getWebdriver(self, driverType): if driverType == 'proxy': profile = webdriver.FirefoxProfile() profile.set_preference( "network.proxy.type", 1 ) profile.set_preference( "network.proxy.socks", "127.0.0.1" ) profile.set_preference( "network.proxy.socks_port", 9150 ) profile.set_preference( "network.proxy.socks_remote_dns", True ) profile.set_preference( "places.history.enabled", False ) profile.set_preference( "privacy.clearOnShutdown.offlineApps", True ) profile.set_preference( "privacy.clearOnShutdown.passwords", True ) profile.set_preference( "privacy.clearOnShutdown.siteSettings", True ) profile.set_preference( "privacy.sanitize.sanitizeOnShutdown", True ) profile.set_preference( "signon.rememberSignons", False ) profile.set_preference( "network.cookie.lifetimePolicy", 2 ) profile.set_preference( "network.dns.disablePrefetch", True ) profile.set_preference( "network.http.sendRefererHeader", 0 ) profile.set_preference( "javascript.enabled", False ) profile.set_preference( "permissions.default.image", 2 ) return webdriver.Firefox(profile) elif driverType == 'headless': return webdriver.PhantomJS() else: return webdriver.Firefox()
Example #11
Source File: worker.py From alma-slipsomat with MIT License | 6 votes |
def get_driver(self): # Start a new browser and return the WebDriver browser_name = self.config.get('selenium', 'browser') if browser_name == 'firefox': from selenium.webdriver import Firefox return Firefox() if browser_name == 'chrome': from selenium.webdriver import Chrome return Chrome() if browser_name == 'phantomjs': from selenium.webdriver import PhantomJS return PhantomJS() # @TODO: Add chrome raise RuntimeError('Unsupported/unknown browser')
Example #12
Source File: instagramfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #13
Source File: webapp.py From python-selenium-bdd with MIT License | 5 votes |
def __init__(self): if str(settings['browser']).lower() is "firefox": self.driver = webdriver.Firefox() elif str(settings['browser']).lower() is "chrome": self.driver = webdriver.Chrome() else: self.driver = webdriver.Firefox()
Example #14
Source File: browser.py From QRLJacking with GNU General Public License v3.0 | 5 votes |
def new_session(self, module_name, url, useragent="(random)"): if self.browsers!={} and module_name in list(self.browsers.keys()) and self.browsers[module_name]["Status"]: return {"Status":"Duplicate"} else: new_headless = {module_name:{"host":"","port":""}} new_headless[module_name]["url"] = url if not useragent.strip(): # This if condition is useless because module won't let the useragent to be empty but I will leave it just in case... return {"Status":"Invalid useragent"} else: profile = generate_profile(useragent) try: #TODO new_headless[module_name]["Controller"] = None if Settings.debug: new_headless[module_name]["Controller"] = Firefox(profile)#options=self.opts) # Inserting the browser object else: new_headless[module_name]["Controller"] = Firefox(profile, options=self.opts) # Inserting the browser object except Exception as e: if Settings.debug: print(" Exception: "+str(e)) print(" Trackback: ") traceback.print_exc() return {"Status":"Failed"} else: new_headless[module_name]["Status"] = "Success" self.browsers.update(new_headless) new_headless[module_name]["Controller"].get(url) self.useragent = new_headless[module_name]["Controller"].execute_script("return navigator.userAgent;") return new_headless[module_name]
Example #15
Source File: SeleniumTester.py From civet with Apache License 2.0 | 5 votes |
def create_firefox_driver(cls): """ Instructions to get this working: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver Driver can be found here: https://github.com/mozilla/geckodriver/releases Important: After downloading the driver, rename it to 'wires' and put it in your path and chmod 755 """ from selenium.webdriver.common.desired_capabilities import DesiredCapabilities cap = DesiredCapabilities.FIREFOX cap['marionette'] = True driver = webdriver.Firefox(capabilities=cap) driver.implicitly_wait(2) return driver
Example #16
Source File: xos-e2e-test.py From xos with Apache License 2.0 | 5 votes |
def setUp(self): if hasattr(self, "browser") and self.browser == "firefox": self.driver = webdriver.Firefox() elif hasattr(self, "browser") and self.browser == "chrome": self.driver = webdriver.Chrome() else: self.driver = webdriver.PhantomJS() self.driver.set_window_size(1920, 1280) self.driver.get(self.url)
Example #17
Source File: conftest.py From tau-pytest-bdd with Apache License 2.0 | 5 votes |
def browser(): # For this example, we will use Firefox # You can change this fixture to use other browsers, too. # A better practice would be to get browser choice from a config file. b = webdriver.Firefox() b.implicitly_wait(10) yield b b.quit() # Shared Given Steps
Example #18
Source File: webdriver.py From pycopia with Apache License 2.0 | 5 votes |
def initialize(self): cf = self.config profile_dir = cf.userconfig.get("firefox_profile") self.info("Firefox profile dir: {}".format(profile_dir)) profile = webdriver.FirefoxProfile(profile_dir) profile.accept_untrusted_certs = True cf.webdriver = webdriver.Firefox(profile)
Example #19
Source File: main.py From SneakerBotTutorials with MIT License | 5 votes |
def startDriver(self, proxy=None): if proxy != None: # This means the user defined the proxy on init driver = createHeadlessBrowser(proxy=proxy) #driver = webdriver.Firefox() # Starts a phantomJS instance with that proxy else: # The user did not define a proxy driver = createHeadlessBrowser() # Creates a phantomJS instance without a proxy try: # Tries to navigate to the URL print("Getting {}".format(self.targetURL)) driver.get(self.targetURL) except Exception as exp: print("ERROR ON {}".format(exp)) # This means the navigation failed, and the proxy is likely not working driver.close() # Closes out the driver self.failedProxies.append(proxy) # Appends the proxy to the failed proxy list return # Returns none self.driverList.append({'driver': driver, 'proxy': proxy}) # Appends the open webdriver instance to driverList self.driverInfo.append({'proxy': proxy, 'driver': driver, 'url': self.targetURL, 'useragent': self.headers}) # Appens the open webdriver instance to the driverInfo list self.successProxies.append(proxy) # This adds the proxy to the list of working proxies if self.saveSS == True: # The program takes a screenshot driver.save_screenshot(SS_FORMAT.format(proxy.partition(':')[0])) # Saves the screenshot locally if VERBOSE_MODE == True: print("started {} driver".format(proxy)) # Prints out the proxy ip for the webdriver instance
Example #20
Source File: main.py From SneakerBotTutorials with MIT License | 5 votes |
def grabSS(proxy): #converts phantomjs cookies into firefox webdriver to check out while True: try: headers = RandomHeaders.LoadHeader() # Generates a random header driver = webdriver.PhantomJS(service_args=['--proxy={}'.format(proxy), '--proxy-type=https']) # Starts a phantomJS instance with a proxy and random header driver.get(URL) # Navigates to a URL while driver.title == SPLASHTITLE: # This means the driver title matches the title of the target page # ie: the yeezy splash page driver.save_screenshot('{}.png'.format(proxy.replace(':', '').replace('.', ''))) #this just visualizes the phantomjs driver - you can replace this with pass if you're trying to reduce processing cookies_list = driver.get_cookies() # This contains the cookies in the driver # Ideally this would be the point that the driver passes the splash page driver.close() # Closes out this driver driver.quit() # Closes out this driver driver = webdriver.Firefox(service_args=['--proxy={}'.format(proxy), '--proxy-type=https']) # Opens up a new FIREFOX non-Headless browser window that the user can control driver.get(URL) # Navigate to the same URL # You can only set cookies for the driver's current domain so visit the page first then set cookies driver.delete_all_cookies() # Precautionary - delete all cookies first for cookie in cookies_list: # Loops through all of the cookies if "adidas" in cookie['domain']: # Only looking for Adidas cookies driver.add_cookie(cookie) # Adds adidas cookies to the driver driver.refresh() # once cookies are changed browser must be refreshed except Exception as exp: # Problem with the function print exp
Example #21
Source File: SeleniumTester.py From civet with Apache License 2.0 | 5 votes |
def setUpClass(cls): cls.drivers = WebDriverList( cls.create_chrome_driver(), # The firefox driver doesn't seem to work properly anymore. Firefox 48, Selenium 0.9.0. # innerHTML never gets set so many of the tests break # cls.create_firefox_driver(), ) super(SeleniumTester, cls).setUpClass() #cls.selenium = cls.create_firefox_driver() #cls.selenium.implicitly_wait(2) #cls.selenium = cls.create_chrome_driver()
Example #22
Source File: vkontaktefinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #23
Source File: doubanfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #24
Source File: linkedinfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #25
Source File: facebookfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #26
Source File: pinterestfinder.py From social_mapper with GNU General Public License v3.0 | 5 votes |
def __init__(self,showbrowser): display = Display(visible=0, size=(1600, 1024)) display.start() if not showbrowser: os.environ['MOZ_HEADLESS'] = '1' firefoxprofile = webdriver.FirefoxProfile() firefoxprofile.set_preference("permissions.default.desktop-notification", 1) firefoxprofile.set_preference("dom.webnotifications.enabled", 1) firefoxprofile.set_preference("dom.push.enabled", 1) self.driver = webdriver.Firefox(firefox_profile=firefoxprofile) self.driver.implicitly_wait(15) self.driver.delete_all_cookies()
Example #27
Source File: __init__.py From selenium-python-helium with MIT License | 5 votes |
def _start_firefox_driver(self, headless, options): firefox_options = self._get_firefox_options(headless, options) kwargs = self._get_firefox_driver_kwargs(firefox_options) result = Firefox(**kwargs) atexit.register(self._kill_service, result.service) return result
Example #28
Source File: scraper.py From facebook-scraper-selenium with GNU General Public License v3.0 | 5 votes |
def __init__(self, ids=["oxfess"], file="posts.csv", depth=5, delay=2): self.ids = ids self.out_file = file self.depth = depth + 1 self.delay = delay # browser instance self.browser = webdriver.Firefox(executable_path=GECKODRIVER, firefox_binary=FIREFOX_BINARY, firefox_profile=PROFILE,) utils.create_csv(self.out_file)
Example #29
Source File: DriverFactory.py From qxf2-page-object-model with MIT License | 5 votes |
def get_firefox_driver(self): "Return the Firefox driver" driver = webdriver.Firefox(firefox_profile=self.get_firefox_profile()) return driver
Example #30
Source File: tntapi.py From 20up with GNU General Public License v3.0 | 5 votes |
def __init__(self, browser): self.driver = '' try: if browser == 'ch': self.driver = webdriver.Chrome() elif browser == 'fi': self.driver = webdriver.Firefox() else: raise RuntimeError('El navegador web elegido no esta soportado por 20up') except: raise RuntimeError('Imposible abrir el navegador web; por favor, elige otro') self.driver.get(URLS['login'])