def open_base_url(set_browser, set_base_url): base_url = set_base_url driver = set_browser browser.set_driver(driver) driver.maximize_window() config.timeout = 10 browser.open_url(base_url) yield driver driver.quit()
def open_base_url(set_browser, set_base_url): base_url = set_base_url driver = set_browser browser.set_driver(driver) driver.maximize_window() config.timeout = 10 browser.open_url(base_url) HomepageLocators.schedule_an_appointment_icon.should(be.visible) yield driver driver.quit()
def set_browser(): """Настроить браузер""" options = Options() options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--disable-gpu') driver = webdriver.Chrome(executable_path=chromedriver_path, options=options) driver.maximize_window() config.timeout = 10 browser.set_driver(driver)
def setup(): options = Options() options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--disable-gpu') options.add_argument('--window-size=1920x1080') driver = webdriver.Chrome(executable_path=chromedriver_path, options=options) driver.maximize_window() config.timeout = 10 browser.set_driver(driver)
def web_driver(docker, selenoid_host, browser_name, browser_version, vnc, video): if docker: driver = get_selenoid_web_driver(selenoid_host, browser_name, browser_version, vnc, video) elif browser_name == "firefox": driver = get_firefox_web_driver() else: driver = get_chrome_web_driver(is_headless=False) browser.set_driver(driver) yield browser.driver() browser.quit()
}) # start capturing HAR data bmp_client.new_har(options={"captureHeaders": True, "captureContent": True}) bmp_client.new_page(ref="slow_internet") # update the browser settings capabilities = webdriver.DesiredCapabilities.FIREFOX.copy() capabilities["acceptInsecureCerts"] = True bmp_client.add_to_webdriver_capabilities(capabilities) # launch the web browser driver = webdriver.Remote("http://selenium-hub:4444/wd/hub", capabilities) # give up to 10 minutes for the page to load driver.set_page_load_timeout(600) browser.set_driver(driver) try: # navigate the web browser to the web application front page browser.open_url(url) except Exception as ex: print(ex) finally: # close the web browser browser.quit() # save the har with open(f'{int(time.time())}.har', 'w') as outfile: json.dump(bmp_client.har, outfile) # kill the bmp client
import pytest from selenium.webdriver.chrome.options import Options from selenium import webdriver from selene.api import browser from selene import config options = Options() options.add_argument('--no-sandbox') chrome = webdriver.Chrome(chrome_options=options) config.timeout = 10 browser.set_driver(chrome) chrome.set_window_size("1920", "1080") @pytest.fixture(scope='session') def setup(): yield chrome.quit()