Beispiel #1
0
def browser(request):
    language = request.config.getoption("language")

    if language not in ["ru", "en-GB", "es", "fr"]:
        raise pytest.UsageError("Test should contain language")

    driver = request.config.getoption("browser")

    if driver not in ["chrome", "firefox"]:
        raise pytest.UsageError("I don't know your browser, bitch!")

    options = Options()
    options.add_experimental_option("prefs", {"intl.accept_languages": language})

    profile = FirefoxProfile()
    profile.set_preference("intl.accept_languages", language)

    print("\nstart " + driver + " for test..")
    if driver == "chrome":
        web_page = webdriver.Chrome(options=options)
    else:
        web_page = webdriver.Firefox(firefox_profile=profile)
        # web_page.implicitly_wait(5)
    web_page.user_language = language

    yield web_page

    print("\nquit browser..")
    web_page.quit()
def prepare_sniper_profile(default_profile_path):
    profile = FirefoxProfile(default_profile_path.resolve())
    profile.set_preference('dom.webdriver.enabled', False)
    profile.set_preference('useAutomationExtension', False)
    if os.path.isfile('./recaptcha_solver-5.7-fx.xpi'):
        profile.add_extension('recaptcha_solver-5.7-fx.xpi')
    profile.update_preferences()
    return profile
Beispiel #3
0
    def __init__(self,
                 headless=True,
                 fake_media: bool = True,
                 *args,
                 **kwargs):
        self.fake_media = fake_media
        self.options = Options()
        self.options.headless = headless
        self.profile = FirefoxProfile()
        self._set_options()
        self.profile.update_preferences()

        super().__init__(options=self.options,
                         firefox_profile=self.profile,
                         *args,
                         **kwargs)
Beispiel #4
0
def caps():
    profile = FirefoxProfile()
    profile.set_preference(
        "general.useragent.override",
        "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"
    )
    profile.set_preference("intl.accept_languages", 'en-us')
    return profile
Beispiel #5
0
def prepare_sniper_profile(default_profile_path):
    sniper_profile_path = default_profile_path.parent / 'sniper.default-release'

    shutil.rmtree(sniper_profile_path, ignore_errors=True)
    shutil.copytree(
        default_profile_path,
        sniper_profile_path,
        ignore=lambda _, __: ['lock', '.parentlock', 'parent.lock'])

    shutil.rmtree(sniper_profile_path / 'datareporting')
    shutil.rmtree(sniper_profile_path / 'extensions')
    shutil.rmtree(sniper_profile_path / 'storage')

    os.remove(sniper_profile_path / 'webappsstore.sqlite')
    os.remove(sniper_profile_path / 'favicons.sqlite')
    os.remove(sniper_profile_path / 'places.sqlite')

    profile = FirefoxProfile(sniper_profile_path.resolve())
    profile.set_preference('dom.webdriver.enabled', False)
    profile.set_preference('useAutomationExtension', False)
    profile.update_preferences()
    return profile
Beispiel #6
0
                               'Do you want to disable image loading?',
                               indicator='=>')
    no_image_loading = no_image_loading == 'Yes'

    timeout, _ = pick(
        [' 2 seconds', ' 4 seconds', ' 8 seconds', '16 seconds', '32 seconds'],
        'Please choose a timout / refresh interval',
        indicator='=>',
        default_index=2)
    timeout = int(timeout.replace('seconds', '').strip())

    randomstring = ''.join(
        random.choice(string.ascii_lowercase) for i in range(10))
    startnumber = 0

    profile = FirefoxProfile()
    if no_image_loading:
        profile.set_preference('permissions.default.image', 2)

    driver = webdriver.Firefox(firefox_profile=profile)

    while True:
        anticache = "?" + str(randomstring) + "=" + str(startnumber)
        success = checkout.add_to_basket(driver, timeout, customer['locale'],
                                         target_url, anticache)
        if success:
            checkout.to_checkout(driver, timeout, customer['locale'])
            if payment_method == 'credit-card':
                checkout.checkout_guest(driver, timeout, customer, auto_submit)
            else:
                checkout.checkout_paypal(driver, timeout),
Beispiel #7
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import TimeoutException,JavascriptException,WebDriverException
from selenium.webdriver.firefox.options import Options,FirefoxBinary,FirefoxProfile
from tqdm import tqdm

torPath = "../tor-browser-patched/Primary/start-tor-browser.desktop"
profilePath = "../tor-browser-patched/Primary/Browser/TorBrowser/Data/Browser/profile.default"
profile = FirefoxProfile(profilePath)
profile.set_preference("webdriver.load.strategy", "unstable")
binary = FirefoxBinary(torPath)
driver = webdriver.Firefox(firefox_binary=binary,firefox_profile=profile)

driver.get('www.google.com')
Beispiel #8
0
def prepare_sniper_profile(default_profile_path):
    profile = FirefoxProfile(default_profile_path.resolve())
    profile.set_preference('dom.webdriver.enabled', False)
    profile.set_preference('useAutomationExtension', False)
    profile.update_preferences()
    return profile
Beispiel #9
0
class Firefox(webdriver.Firefox, ABCWipeDriver):
    def __init__(self,
                 headless=True,
                 fake_media: bool = True,
                 *args,
                 **kwargs):
        self.fake_media = fake_media
        self.options = Options()
        self.options.headless = headless
        self.profile = FirefoxProfile()
        self._set_options()
        self.profile.update_preferences()

        super().__init__(options=self.options,
                         firefox_profile=self.profile,
                         *args,
                         **kwargs)

    def send_keys_to_url_bar(self, *value) -> None:
        url_bar = self.find_element_by_id('urlbar')
        url_bar.send_keys(value)

    def open_new_tab(self) -> None:
        current_windows_count = len(self.window_handles)
        self.execute_script('window.open();')
        WebDriverWait(self, self.max_timeout * 2).until(
            EC.number_of_windows_to_be(current_windows_count + 1), )
        self.switch_tab_forward()

    def close_tab(self) -> None:
        if len(self.window_handles) > 1:
            self.close()
            self.switch_tab_back()

    def _set_options(self):
        self.profile.set_preference('media.navigator.permission.disabled',
                                    True)
        self.profile.set_preference('permissions.default.microphone', 0)
        self.profile.set_preference('permissions.default.camera', 0)
        self.profile.set_preference('browser.tabs.remote.autostart', True)
        self.profile.set_preference('browser.privatebrowsing.autostart', True)
        self.profile.set_preference('media.volume_scale', '0.0')
        self.profile.set_preference('permissions.default.image', 2)
        if self.fake_media:
            self.options.set_preference('media.navigator.streams.fake', True)
Beispiel #10
0
    auto_submit, _ = pick(
        ['Yes', 'No'],
        'Do you want to automatically submit the order? (only works with credit card)',
        indicator='=>',
        default_index=1)
    auto_submit = auto_submit == 'Yes'

    timeout, _ = pick(
        [' 2 seconds', ' 4 seconds', ' 8 seconds', '16 seconds', '32 seconds'],
        'Please choose a timout / refresh interval',
        indicator='=>',
        default_index=2)
    timeout = int(timeout.replace('seconds', '').strip())

    default_profile = get_default_profile().resolve()
    profile = FirefoxProfile(default_profile)
    profile.set_preference('dom.webdriver.enabled', False)
    profile.set_preference('useAutomationExtension', False)
    profile.update_preferences()

    driver = webdriver.Firefox(firefox_profile=profile,
                               executable_path=GeckoDriverManager().install())

    target_gpu = gpu_data[target_gpu]

    while True:
        logging.info(
            f"Checking {locale} availability for {target_gpu['name']}...")
        checkout.get_product_page(driver, locale, target_gpu)
        gpu_available = checkout.check_availability(driver, timeout)
        if gpu_available: