Exemplo n.º 1
0
    def browser(self):
        config_browser = self.config_browser()
        config_wait_time = self.config_wait_time()
        config_headless = self.headless_browser()

        if config_browser == 'chrome':
            if config_headless == 'yes':
                driver_options = chrome_options()
                driver_options.headless = True
                driver = Chrome(options=driver_options)
            else:
                driver = Chrome()
        elif config_browser == 'firefox':
            if config_headless == 'yes':
                driver_options = ff_options()
                driver_options.headless = True
                driver = Firefox(options=driver_options)
            else:
                driver = Firefox()
        elif config_browser == 'opera':
            if config_headless == 'yes':
                driver_options = opera_options()
                driver_options.headless = True
                driver = Opera(options=driver_options)
            else:
                driver = Opera()
        else:
            raise Exception(f'"{config_browser}" is not a supported browser')

        driver.implicitly_wait(config_wait_time)

        return driver
Exemplo n.º 2
0
def create_instance(*, headless=False, auto_quit=True, user_data_dir=None, executable_path=None) -> Opera:
    """Creates Opera webdriver instance using the provided arguments."""

    _log.debug("creating webdriver: Opera(headless=%s, auto_quit=%s, user_data_dir='%s', executable_path='%s')",
               headless, auto_quit, user_data_dir, executable_path)

    options = get_options(headless=headless, user_data_dir=user_data_dir)
    driver = Opera(options=options, executable_path=executable_path)
    _log.debug("created webdriver: Opera")

    if auto_quit:
        atexit.register(driver.quit)

    return driver
Exemplo n.º 3
0
    def test_cartCost(self):
        opts = Options()
        opts.headless = True
        assert opts.headless  # без графического интерфейса.
        browser = Opera(options=opts)

        browser.get('https://luch.by/kollektsii/volat-2-0/728377624/')
        item1Price = int(browser.find_element_by_class_name('styled-price').text[:-4])
        browser.find_element_by_class_name('button_add').click()

        browser.get('https://luch.by/kollektsii/classic/76730567/')
        item2Price = int(browser.find_element_by_class_name('styled-price').text[:-4])
        browser.find_element_by_class_name('button_add').click()

        browser.get('https://luch.by/cart/')
        total = int(browser.find_element_by_class_name('styled-price').text[:-4])
        self.assertEqual(total, item1Price+item2Price)
Exemplo n.º 4
0
from selenium.webdriver import Opera

browser = Opera(executable_path="/Users/macbook/webdriver/operadriver")
browser.get('https://mail.ru')
browser.find_element_by_name("login").send_keys('*****@*****.**')
browser.find_element_by_id("mailbox:submit").click()
browser.implicitly_wait(5)
browser.find_element_by_name("password").send_keys('O+ryrpoAOY24')
browser.find_element_by_id("mailbox:submit").click()
print(browser.title)
def start_browsing(site):
    driver = Opera()
    driver.get(site)
    # be sure we are in stack overflow
    assert 'Stack Overflow' in driver.title, 'It seems like its not Stack Overflow'
    return driver
Exemplo n.º 6
0
 def __init__(self):
     self.driver = Opera(executable_path='./operadriver')
     self.driver.get("https://nofluffjobs.com/pl")
     self.driver.fullscreen_window()
     self.jobs_descriptions = []
     self.jobs_links = []