示例#1
0
def demo_chrome():
    import time
    from selenium import webdriver
    import selenium.webdriver.chrome.service as service
    service = service.Service(
        '/Users/tv365/code/ant/src/config/chromedriver_mac243')
    service.start()
    # capabilities = {'chrome.binary': '/path/to/custom/chrome'}
    # driver = webdriver.Remote(service.service_url, capabilities)
    urls = [
        url.replace('\n', '')
        for url in open('/data/my_ant/play_urls').readlines()
    ]
    for i, url in enumerate(random.sample(urls, 10)):
        opts = ChromeOptions()
        opts.add_argument('--no-sandbox')
        opts.add_argument('--disable-dev-shm-usage')
        dcap = dict(DesiredCapabilities.CHROME)
        dcap["chrome.page.settings.loadImages"] = False
        opts.add_argument("--headless")
        driver = webdriver.Remote(service.service_url,
                                  options=opts,
                                  desired_capabilities=dcap)
        driver.get('http://www.google.com/xhtml')
        time.sleep(5)  # Let the user actually see something!
        driver.save_screenshot(str(i) + '.png')
        driver.quit()
    pass
示例#2
0
def newCDS():
    global service
    #https://duo.com/decipher/driving-headless-chrome-with-python    
    print('Starting chromedriverService at...', end='')
    service = service.Service('/usr/local/bin/chromedriver')
    service.start()
    CDS=service.service_url
    print( CDS )
    return CDS
示例#3
0
def openChrome():
    global driver, strict
    service.start()
    driver = webdriver.Remote(service.service_url, capabilities)

    inp = input('Do you want to use strict item selection? [Y]es/[N]o: ')
    if inp.upper() == 'YES' or inp.upper() == 'Y':
        strict = True
    else:
        strict = False

    returnTime()
    for it in items:
        searchItem(it)
示例#4
0
def init_driver_chrome():
    '''
    Initialize chrome browser. it needs a webdriver service
    '''
    import selenium.webdriver.chrome.service as service
    global service  # global variable because its needed in quit_driver()
    service = service.Service('chromedriver')
    service.start()
    print "service initialized for chrome browser"
    
    capabilities = {'chrome.loadAsync': 'true'}
    driver = webdriver.Remote(service.service_url, capabilities)
    driver.wait = WebDriverWait(driver, 5)
    driver.implicitly_wait(10)
    return driver
示例#5
0
import os
import sys
from openpyxl import Workbook
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import selenium.webdriver.chrome.service as service

service = service.Service(os.path.abspath('chromedriver'))
service.start()

chrome_options = Options()
chrome_options.add_argument("--start-maximized")

url = 'https://search.weleakinfo.com/'
search_box_xpath = '//*[@id="main"]/section[2]/div[2]/div[2]/div/form/div/div[2]/input'
search_type_xpath = '//*[@id="main"]/section[2]/div[2]/div[3]/div/button'
results_text_xpath = '//*[@id="results"]/div/div/div/h1'
error_xpath = '//*[@id="results"]/div/div/div[2]/div/p'
search_type_options_xpath = {
    'username': 0,
    'email': 1,
    'password': 2,
    'hash': 3,
    'ip': 4,
    'name': 5,
    'phone': 6
}
finalResultsForXLS = []
wb = Workbook()
sheet = wb.active
file = open("emails.txt", "r+");
x = file.read();

target_size = 10
count = len(x) / target_size;

emails = [ x[i:i+target_size] for i in range(0, len(x), target_size) ];

file.close();


# Connect to google.com to start sign up on the accounts

service = service.Service('../chromedriver');
service.start()
capabilities = {'chrome.binary': ''} # Enter path to chrome.exe in windows inside the '' tags.

driver = webdriver.Remote(service.service_url, capabilities);
driver.get('https://accounts.google.com/SignUp');

loopNumber = 0;

while loopNumber < ammount :

	time.sleep(2);

	Fname     = driver.find_element_by_name("FirstName");
	Lname     = driver.find_element_by_name("LastName");
	Address   = driver.find_element_by_name("GmailAddress");
	Password1 = driver.find_element_by_name("Passwd");
示例#7
0
def openService(link):
	service = selenium.webdriver.chrome.service.Service('/Users/sudo/Dropbox/Workspace/Utility/youtubeTomp3/drivers/chromedriver')
	service.start()
	return service
示例#8
0
"""
Use ChromeDriverService to control ChromeDriver's lifetime for large test suites

ChromeDriverService allows start/stop ChromeDriver server
"""

import time
from selenium import webdriver
import selenium.webdriver.chrome.service as cDriverService

chromeDriver = r"C:\Devs\Python\chromedriver.exe"
cDriverService = cDriverService.Service(chromeDriver)
cDriverService.start()
cDriverCapability = {
    "chrome.binary":
    "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
}

driver = webdriver.Remote(cDriverService.service_url, cDriverCapability)
driver.get("https://www.google.co.uk/xhtml")
time.sleep(5)
driver.quit()
示例#9
0
def _get_selenium_browser(navigator, fLOG=noLOG):
    """
    Returns the associated driver with some custom settings.

    The function automatically gets chromedriver if not present (Windows only).

    ..faqref::
        :tag: web
        :title: Issue with Selenium and Firefox
        :lid: faq-web-selenium

        Firefox >= v47 does not work on Windows.
        See `Selenium WebDriver and Firefox 47 <http://www.theautomatedtester.co.uk/blog/2016/selenium-webdriver-and-firefox-47.html>`_.

        Voir `ChromeDriver download <http://chromedriver.storage.googleapis.com/index.html>`_,
        `Error message: 'chromedriver' executable needs to be available in the path <http://stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path>`_.
    """
    from selenium import webdriver
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

    fLOG("navigator=", navigator)
    if navigator == "firefox":
        firefox_capabilities = DesiredCapabilities.FIREFOX.copy()
        firefox_capabilities['marionette'] = True
        firefox_capabilities[
            'binary'] = r"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
        browser = webdriver.Firefox(capabilities=firefox_capabilities)
    elif navigator == "chrome":
        if sys.platform.startswith("win"):
            chromed = where_in_path("chromedriver.exe")
            if chromed is None:
                install_chromedriver(fLOG=fLOG)
                chromed = where_in_path("chromedriver.exe")
                if chromed is None:
                    raise FileNotFoundError(
                        "unable to install chromedriver.exe")
            else:
                fLOG("found chromedriver:", chromed)
        if True:
            fLOG("start", navigator)
            browser = webdriver.Chrome(chromed)
        else:
            # see
            # https://sites.google.com/a/chromium.org/chromedriver/getting-started
            from selenium import webdriver
            import selenium.webdriver.chrome.service as service
            fLOG("create service")
            service = service.Service(chromed)
            fLOG("start service")
            service.start()
            fLOG("declare remote")
            capabilities = {'chrome.binary': chromed}
            browser = webdriver.Remote(service.service_url, capabilities)
    elif navigator == "ie":
        browser = webdriver.Ie()
    elif navigator == "opera":
        if sys.platform.startswith("win"):
            chromed = where_in_path("operadriver.exe")
            if chromed is None:
                install_operadriver(fLOG=fLOG)
                chromed = where_in_path("operadriver.exe")
                if chromed is None:
                    raise FileNotFoundError(
                        "unable to install chromedriver.exe")
            else:
                fLOG("found chromedriver:", chromed)
        browser = webdriver.Opera()
    elif navigator == "edge":
        browser = webdriver.Opera()
    else:
        raise Exception(
            "unable to interpret the navigator '{0}'".format(navigator))
    fLOG("navigator is started")
    return browser
示例#10
0
def _get_selenium_browser(navigator, fLOG=noLOG):
    """
    Returns the associated driver with some custom settings.

    The function automatically gets chromedriver if not present (Windows only).

    ..faqref::
        :tag: web
        :title: Issue with Selenium and Firefox
        :lid: faq-web-selenium

        Firefox >= v47 does not work on Windows.
        See `Selenium WebDriver and Firefox 47 <http://www.theautomatedtester.co.uk/blog/2016/selenium-webdriver-and-firefox-47.html>`_.

        Voir `ChromeDriver download <http://chromedriver.storage.googleapis.com/index.html>`_,
        `Error message: 'chromedriver' executable needs to be available in the path <http://stackoverflow.com/questions/29858752/error-message-chromedriver-executable-needs-to-be-available-in-the-path>`_.
    """
    from selenium import webdriver
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

    fLOG("navigator=", navigator)
    if navigator == "firefox":
        firefox_capabilities = DesiredCapabilities.FIREFOX.copy()
        firefox_capabilities['marionette'] = True
        firefox_capabilities[
            'binary'] = r"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
        browser = webdriver.Firefox(capabilities=firefox_capabilities)
    elif navigator == "chrome":
        if sys.platform.startswith("win"):
            chromed = where_in_path("chromedriver.exe")
            if chromed is None:
                install_chromedriver(fLOG=fLOG)
                chromed = where_in_path("chromedriver.exe")
                if chromed is None:
                    raise FileNotFoundError(
                        "unable to install chromedriver.exe")
            else:
                fLOG("found chromedriver:", chromed)
        if True:
            fLOG("start", navigator)
            browser = webdriver.Chrome(chromed)
        else:
            # see
            # https://sites.google.com/a/chromium.org/chromedriver/getting-started
            from selenium import webdriver
            import selenium.webdriver.chrome.service as service
            fLOG("create service")
            service = service.Service(chromed)
            fLOG("start service")
            service.start()
            fLOG("declare remote")
            capabilities = {'chrome.binary': chromed}
            browser = webdriver.Remote(service.service_url, capabilities)
    elif navigator == "ie":
        browser = webdriver.Ie()
    elif navigator == "opera":
        if sys.platform.startswith("win"):
            chromed = where_in_path("operadriver.exe")
            if chromed is None:
                install_operadriver(fLOG=fLOG)
                chromed = where_in_path("operadriver.exe")
                if chromed is None:
                    raise FileNotFoundError(
                        "unable to install chromedriver.exe")
            else:
                fLOG("found chromedriver:", chromed)
        browser = webdriver.Opera()
    elif navigator == "edge":
        browser = webdriver.Opera()
    else:
        raise Exception(
            "unable to interpret the navigator '{0}'".format(navigator))
    fLOG("navigator is started")
    return browser