def test_we_can_launch_multiple_ie_instances():
    driver1 = Ie()
    driver2 = Ie()
    driver3 = Ie()
    driver1.quit()
    driver2.quit()
    driver3.quit()
Exemple #2
0
def browser(config_browser, config_headless_mode, request):
    if config_browser == 'chrome':
        options = ChromeOptions()
        options.headless = config_headless_mode
        options.add_argument('--no-sandbox')
        options.add_argument('--disable-dev-shm-usage')
        # mobile_emulation = {"deviceName": "Nexus 5"}
        # options.add_experimental_option("mobileEmulation", mobile_emulation)
        driver = Chrome(options=options)
    elif config_browser == 'firefox':
        options = FirefoxOptions()
        options.headless = config_headless_mode
        options.add_argument('--no-sandbox')
        options.add_argument('--disable-dev-shm-usage')
        driver = Firefox(options=options)
    elif config_browser == 'ie':
        if config_headless_mode:
            Warning("Headless mode is not supported in IE")
        driver = Ie()
    else:
        raise Exception(f'"{config_browser}" is not a supported browser')
    driver.delete_all_cookies()
    driver.set_window_size(1920, 1080)
    driver.implicitly_wait(wait_time)

    # Return the driver object at the end of setup
    yield driver

    # For cleanup, quit the driver
    driver.quit()
Exemple #3
0
    def __init__(self,
                 options=None,
                 user_agent=None,
                 wait_time=2,
                 fullscreen=False,
                 incognito=False,
                 headless=False,
                 **kwargs):

        options = Options() if options is None else options

        if user_agent is not None:
            options.add_argument("--user-agent=" + user_agent)

        if incognito:
            options.add_argument("--incognito")

        if fullscreen:
            options.add_argument("--kiosk")

        if headless:
            options.add_argument("--headless")
            options.add_argument("--disable-gpu")

        self.driver = Ie(options=options, **kwargs)

        self.element_class = WebDriverElement

        self._cookie_manager = CookieManager(self.driver)

        super(WebDriver, self).__init__(wait_time)
 def launch_application(browser_name, app_url):
     global driver
     log.info("in init method of selenium base")
     try:
         if browser_name == "chrome":
             option = ChromeOptions()
             option.add_argument("start-maximized")
             option.add_argument("--ignore-certificate-errors")
             option.add_argument("--disable-extensions")
             option.add_argument("--disable-infobars")
             option.add_argument("disable-notifications")
             driver = Chrome(executable_path="./drivers/chromedriver.exe",
                             options=option)
             log.info("chrome browser is launch successfully")
         elif browser_name == "firefox":
             profile = FirefoxProfile()
             profile.accept_untrusted_certs = True
             options = FirefoxOptions()
             options.add_argument("start-maximized")
             driver = Firefox(executable_path="./drivers/geckodriver.exe")
             log.info("firefox browser is launch successfully")
         elif browser_name == "ie":
             driver = Ie(executable_path="./drivers/IEDriverServer.exe")
         else:
             log.error("browser name is incorrect", browser_name)
     except WebDriverException:
         log.critical("exception", WebDriverException)
     driver.implicitly_wait(5)
     driver.get(app_url)
Exemple #5
0
def get_driver_instance():
    parser = ArgumentParser()
    parser.add_argument("--browser", default="firefox")
    parser.add_argument("--url", default="test")
    parser.add_argument("--env", default="windows")

    options, arg = parser.parse_known_args()

    browser_type = options.browser.lower()
    url_info = options.url.lower()
    env_info = options.env.lower()

    if browser_type == "chrome":
        driver = Chrome("./browser-servers/chromedriver.exe")
    elif browser_type == "firefox":
        driver = Firefox("./browser-servers/geckodriver.exe")
    elif browser_type == "ie":
        driver = Ie("./browser-servers/iedriver.exe")
    else:
        print("-- !!!!!!! not found----!!!!")

    driver.maximize_window()
    driver.implicitly_wait(30)

    if url_info == "prod":
        driver.get("https://actitime.jmr.co.za/actitime/login.do")
    elif url_info == "staging":
        driver.get("https://192.168.1.101/login.html")
    else:
        driver.get("https://demo.actitime.com/login.do ")

    return driver
Exemple #6
0
def startBrowser(request):
    global driver

    browser_name = request.config.getoption("browser_name")
    if browser_name == "firefox":
        path = "./Driver/geckodriver.exe"
        firefox_opt = webdriver.FirefoxOptions()
        firefox_opt.add_argument('--disable-gpu')
        driver = Firefox(executable_path=path, options=firefox_opt)
    elif browser_name == "chrome":
        path = "./Driver/chromedriver.exe"
        chrome_opt = webdriver.ChromeOptions()
        chrome_opt.add_argument('--disable-gpu')
        driver = Chrome(executable_path=path, options=chrome_opt)
    elif browser_name == "Ie":
        path = "./Driver/IEDriverServer.exe"
        driver = Ie(executable_path=path)
    else:
        print("No Browser path found")

    print("Driver Initiating Successfully")
    driver.get("https://opensource-demo.orangehrmlive.com/")
    print("Url Hit Successfully")
    driver.maximize_window()
    request.cls.driver = driver
    yield
    driver.close()
Exemple #7
0
def browser(request, driver_path):

    # setup
    name = request.config.getoption("--browser")
    if name == "Chrome":
        options = ChromeOptions()
        options.add_argument("headless")
        options.add_argument("start-maximized")
        wd = Chrome(executable_path=driver_path+"chromedriver", options=options)
    elif name == "Firefox":
        options = FirefoxOptions()
        options.add_argument("headless")
        options.add_argument("start-maximized")
        wd = Firefox(executable_path=driver_path+"geckodriver", options=options)
    elif name == "Ie":
        options = IeOptions()
        options.add_argument("headless")
        options.add_argument("start-maximized")
        wd = Ie(options=options)
    else:
        print(f"Неизвестный тип браузера \"{name}\"")
        return None

    yield wd

    # teardown
    wd.quit()
Exemple #8
0
    def _set_selenium_driver(self, driver_type, firefox_profile):

        if driver_type == self.DriverType.CHROME:
            self._web_driver = Chrome()

        elif driver_type == self.DriverType.FIREFOX:

            if firefox_profile and os.path.exists(firefox_profile):
                profile = FirefoxProfile(firefox_profile)
                self._web_driver = Firefox(firefox_profile=profile)
            else:
                self._web_driver = Firefox()
        elif driver_type == self.DriverType.IE:
            self._web_driver = Ie()

        elif driver_type == self.DriverType.SAFARI:
            self._web_driver = Safari()

        elif driver_type == self.DriverType.CHROME_HEADLESS:
            profile = ChromeOptions()
            profile.add_argument('headless')
            profile.add_experimental_option("excludeSwitches",
                                            ["ignore-certificate-errors"])
            self._web_driver = Chrome(options=profile)

        else:
            self._web_driver = Chrome()
            print("Invalid Driver Type filled: %r" % driver_type)
Exemple #9
0
def driver(request):
    '''fixture function to instantiate webdriver'''
    browser = request.config.getoption('--browser').lower()
    if browser not in ['ie', 'firefox']:
        raise Exception('Invalid browser option %s' % browser)

    if browser == 'firefox':
        firefoxExe = request.config.getoption('--firefoxbin')
        if not exists(firefoxExe):
            raise Exception('Firefox executable %s not found' % firefoxExe)

    driver = None
    if browser == 'firefox':
        driver = Firefox(firefox_binary=firefoxExe)

    if browser == 'ie':
        # Force IEDriverServer.exe to use the default port
        driver = Ie(port=5555)

    driver.implicitly_wait(30)

    # yield statement turns this fixture function into a generator.  Since
    # this fixture is scoped to the module it gets called once when the module
    # starts.  Presumably at the end of the module the pytest framework calls
    # this fixture generator.  Since there are no more yields the cleanup
    # portion runs.  This is awesome!
    yield driver

    # cleanup the driver
    driver.close()
def test_launch_ie_with_options(pages):
    opts = Options()
    expected = "clicks.html"
    opts.initial_browser_url = pages.url(expected)
    driver = Ie(options=opts)
    actual = driver.current_url
    driver.quit()
    assert expected in actual
Exemple #11
0
 def setup(self):
     self.driver = Ie()
     self.driver.get('https://www09.rminteract.com/')
     self.status = {
         "left": [],
         "duplicate": [],
         "RD1066C": [],
     }
Exemple #12
0
def ie_driver(request, capabilities, driver_path):
    """Return a WebDriver using an Internet Explorer instance"""
    kwargs = {}
    if capabilities:
        kwargs['capabilities'] = capabilities
    if driver_path is not None:
        kwargs['executable_path'] = driver_path
    return Ie(**kwargs)
Exemple #13
0
 def create(self):
     '''
     Create a new driver.
     '''
     return Ie(**filternone(
         port=self.get_port(),
         timeout=self.get_timeout(),
     ))
 def mybrowser(browser):
     driver = None
     str1 = platform.platform()
     op = str1.split("-")[0]
     if op == "Linux":
         if (browser.lower() == "firefox"):
             Firefox_option = fireop()
             fireop.add_argument('--headless')
             driver = Firefox(executable_path=FIREFOX_DIR,
                              firefox_options=Firefox_option)
             Logger.logger.info("启动火狐浏览器,请稍等")
             driver.maximize_window()
         if browser.lower() == "chrome":
             Chrome_option = chop()
             Chrome_option.add_argument('--headless')
             driver = Chrome(executable_path=CHROME_DIR,
                             chrome_options=Chrome_option)
             Logger.logger.info("启动谷歌浏览器,请稍等")
             driver.maximize_window()
         if browser.lower() == "ie":
             op = Options()
             op.add_argument('--headless')
             op.set_capability(op.IGNORE_PROTECTED_MODE_SETTINGS, True)
             driver = Ie(executable_path=IE_DIR, ie_options=op)
             Logger.logger.info("启动ie浏览器,请稍等")
             driver.maximize_window()
     else:
         if (browser.lower() == "firefox"):
             driver = Firefox(executable_path=FIREFOX_DIR)
             Logger.logger.info("启动火狐浏览器,请稍等")
             driver.maximize_window()
         if browser.lower() == "chrome":
             driver = Chrome(executable_path=CHROME_DIR)
             Logger.logger.info("启动谷歌浏览器,请稍等")
             driver.maximize_window()
         if browser.lower() == "ie":
             op.set_capability(op.IGNORE_PROTECTED_MODE_SETTINGS, True)
             driver = Ie(executable_path=IE_DIR)
             Logger.logger.info("启动ie浏览器,请稍等")
             driver.maximize_window()
     return driver
def get_driver_instance():
    browser_type = pytest.config.option.type.lower()
    env= pytest.config.option.env.lower()
    if browser_type=='firefox':
        driver= Firefox('./browser_server/geckodriver.exe')
    elif browser_type== 'Chrome':
        driver = Chrome('./browser_server/chromedriver.exe')
    elif browser_type== 'Ie':
        driver= Ie('./browser_server/iedriver.exe')
    else:
        print('Invalid browser option')
    elif env== 'remote':
        print('Add feature for remote execution')
def get_driver_instance():
    browser_type = pytest.config.option.type.lower()
    env = pytest.config.option.env.lower()
    if env == 'local':
       if browser_type == 'firefox':
           driver = Firefox('./browser_servers/geckodriver.exe')
       elif browser_type == 'chrome':
           driver = Chrome('./browser_servers/chromedriver.exe')
       elif browser_type == 'ie':
            driver = Ie('./browser_servers/IEDriverServer.exe')
    else:
        print ('Invalid Browser Option')
    elif env == 'remote':
        print('Add features for remote execution')
Exemple #17
0
def get_browser_instance():
    browser_type = pytest.config.option.browser
    env = pytest.config.option.env
    url = pytest.config.option.url

    if env == "remote":
        if browser_type == "firefox":
            browser = Firefox(executable_path='d:/geckodriver.exe')
        elif browser_type == "chrome":
            browser = Chrome(executable_path='D:/pyt/chromedriver.exe')
        elif browser_type == "Ie":
            browser = Ie(executable_path='e:/IEDriverServer.exe')
    browser.maximize_window()
    browser.get(url)
    return browser
Exemple #18
0
def browser(request):
    if request.config.getoption("--browser") == "chrome":
        chrome_options = ChromeOptions()
        chrome_options.headless = False
        chrome_options.add_argument('start-fullscreen')
        wd = webdriver.Chrome(options=chrome_options)
        return wd
    elif request.config.getoption("--browser") == "firefox":
        firefox_option = FirefoxOptions()
        wd = webdriver.Firefox(options=firefox_option)
        wd.maximize_window()
        return wd
    elif request.config.getoption("--browser") == "ie":
        ie_option = Ie()
        wd = webdriver.Ie(options=ie_option)
        return wd
Exemple #19
0
    def setUp(self):
        if self.browser_env == 'chrome':
            # this is the setup for working remotely with linux
            # in house just call self.driver = Chrome()
            # Use these commands if you don't want Chrome in headless mode
            options = webdriver.ChromeOptions()
            options.add_argument('--user-agent=piinctest')
            self.driver = webdriver.Chrome(
                executable_path='/usr/local/bin/chromedriver', options=options)

        # Use these commands for Chrome headless
        elif self.browser_env == 'headless':
            options = webdriver.ChromeOptions()
            options.add_argument('headless')
            options.add_argument("--window-size=1920x1080")
            self.driver = webdriver.Chrome(
                executable_path='/usr/local/bin/chromedriver', options=options)

        elif self.browser_env == 'firefox':
            profile = webdriver.FirefoxProfile()
            profile.set_preference("general.useragent.override", "piinctest")
            self.driver = Firefox(profile)

        # Use these commands for Firefox headless
        elif self.browser_env == 'firefoxHeadless':
            options = webdriver.FirefoxOptions()
            options.add_argument('-headless')
            options.add_argument("--window-size=1920x1080")
            self.driver = webdriver.Firefox(
                executable_path='/usr/local/bin/geckodriver', options=options)

        elif self.browser_env == "iexplorer":
            caps = DesiredCapabilities.INTERNETEXPLORER.copy()
            caps["ensureCleanSession"] = True
            # This is set as suggested default path, if you have different path, change it /usr/local/bin
            self.driver = Ie(
                executable_path="C:/webdrivers/iedriverserver.exe",
                capabilities=caps)

        self.driver.delete_all_cookies()
        try:
            self.driver.maximize_window()
        except AttributeError:
            self.driver.set_window_size(1920, 1200)
        except WebDriverException:
            self.driver.set_window_size(1920, 1200)
        self.driver.get(self.BASE_LINK)
Exemple #20
0
def get_driver_instance():
    browser = pytest.config.option.type.lower()
    if browser == "chrome":
        driver = Chrome("./browser-server/chromedriver.exe")

    if browser == "ie":
        driver = Ie("./browser-server/IEDriverServer.exe")

    if browser == "edge":
        driver = edge("./browser-server/MicrosoftWebDriver.exe")

    else:
        print("Invalid Browser Option")
        return None
    driver.maximize_window()
    driver.implicitly_wait(30)
    driver.get("http://localhost")
    return driver
Exemple #21
0
def get_driver_instance():
    browser_type = pytest.config.option.browser.lower()
    os_name = pytest.config.option.system.lower()
    url_info = pytest.config.option.url.lower()
    if os_name == 'windows':
        if browser_type == 'chrome':
            driver = Chrome('./browser_server/chromedriver.exe')
        elif browser_type == 'firefox':
            driver = Firefox('./browser_server/geckodriver.exe')
        elif browser_type == 'ie':
            driver = Ie('./browser_server/iedriver.exe')

        driver.maximize_window()
        driver.implicitly_wait(30)
        if url_info == 'test':
            driver.get('https://demo.actitime.com')
        elif url_info == 'prod':
            driver.get('https://demo.actitime.com')
        return driver
def get_driver_instance():
    browser=pytest.config.option.browser.lower()
    url=pytest.config.option.server.lower()
    if browser=='firefox':
        driver=Firefox("./browser-servers/geckodriver.exe")
    elif browser=='chrome':
        driver=Chrome("./browser-servers/chromedriver.exe")
    elif browser=='ie':
        driver=Ie("./browser-servers/internetexplorerdriver.exe")
    else:
        print("------invalid browser------")
        return None
    driver.maximize_window()
    driver.implicitly_wait(30)
    if url=='prod':
        driver.get("https://demo.actitime.com")
    else:
        driver.get("https://demo.actitime.com")
    return driver
def get_driver_instance():
    browser = pytest.config.option.type
    env = pytest.config.option.env
    if browser.lower() == 'chrome':
        driver = Chrome('./browser-servers/chromedriver.exe')
    elif browser.lower() == 'firefox':
        driver = Firefox('./browser-servers/geckodriver.exe')
    elif browser.lower() == 'ie':
        driver = Ie('./browser-servers/IEDriverServer.exe')
    else:
        print('---------Invalid Browser option---------')
    driver.maximize_window()
    driver.implicitly_wait(30)
    if env.lower() == 'test':
        driver.get('http://localhost')
    elif env.lower() == 'prod':
        driver.get('http://www.facebook.com')
    else:
        print('--------Invalid Application URL----------')
    return driver
def get_driver_instance():
    browser_type = pytest.config.option.type.lower()
    env = pytest.config.option.env.lower()
    if env == 'local':
        if browser_type == 'firefox':
            driver = Firefox('./browser_servers/geckodriver.exe')
        elif browser_type == 'chrome':
            driver = Chrome('./browser_servers/chromedriver.exe')
        elif browser_type == 'ie':
            driver = Ie('./browser_servers/IEDriverServer.exe')
        else:
            print('Invalid Browser Option')
    elif env == 'remote':
        print('Add features for remote execution')
    else:
        print('Invalid Env option')
        driver.maximize_window()
        driver.implicitly_wait(30)
        driver.get('http://localhost')
        return driver
def get_driver_instance():
    browser_type = pytest.config.option.browser
    system_info = pytest.config.option.system
    url_info = pytest.config.option.url
    if system_info == 'windows':
        if browser_type != 'safari':
            driver = Chrome("./browser-servers/chromedriver.exe")
        elif browser_type == 'firefox':
            driver = Firefox("./browser_type/geckodriver.exe")
        elif browser_type == 'ie':
            driver = Ie("./browser_type/IEDriverServer.exe")
    elif system_info == 'mac':
        pass
    if url_info == 'test':
        driver.get("http://localhost/login.do")
    elif url_info == 'prod':
        driver.get("https://demo.actitime.com/login.do")
    driver.maximize_window()
    driver.implicitly_wait(30)
    return driver
def get_driver_instance():
    browser = pytest.config.option.browser.lower()
    url = pytest.config.option.server.lower()

    if browser == 'firefox':
        driver = Firefox("./browser-servers/geckodriver.exe")
    elif browser == 'chrome':
        driver = Chrome("./browser-servers/chromedriver.exe")
    elif browser == 'ie':
        driver = Ie("./browser-servers/IEDriverServer.exe")
    else:
        print('invalid browser option')
        return None
    driver.maximize_window()
    driver.implicitly_wait(30)
    if url == 'prod':
        driver.get('https://10.62.144.143:57302/')
    else:
        driver.get("https://10.62.144.143:57302/")
    return driver
Exemple #27
0
def browser(config_browser, config_wait_time, request):
    # Initialize WebDriver
    if config_browser == 'chrome':
        driver = Chrome()
    elif config_browser == 'firefox':
        driver = Firefox()
    elif config_browser == 'Ie':
        driver = Ie()
    else:
        raise Exception(f'"{config_browser}" is not a supported browser')

    # Wait implicitly for elements to be ready before attempting interactions
    driver.implicitly_wait(config_wait_time)
    driver.maximize_window()
    failed_before = request.session.testsfailed

    # Return the driver object at the end of setup
    yield driver

    # For cleanup, quit the driver
    driver.quit()
def browsers(request):
    if request.config.getoption("--browser") == "chrome":
        chrome_options = ChromeOptions()
        chrome_options.headless = False
        chrome_options.add_argument('start-fullscreen')
        wd = webdriver.Chrome(options=chrome_options)
        wd.implicitly_wait(4)
        return wd
    elif request.config.getoption("--browser") == "firefox":
        firefox_option = FirefoxOptions()
        wd = webdriver.Firefox(options=firefox_option)
        wd.maximize_window()
        wd.implicitly_wait(3)
        return wd
    elif request.config.getoption("--browser") == "ie":
        ie_option = Ie()
        wd = webdriver.Ie(options=ie_option)
        wd.implicitly_wait(3)
        return wd
    else:
        raise Exception(f"{request.param} is not supported!")
Exemple #29
0
def get_driver_instance():
    browser = pytest.config.option.browser.lower()
    url = pytest.config.option.server.lower()

    if browser == 'firefox':
        driver = firefox("./browser-servers/geckodriver.exe")
    elif browser == 'chrome':
        driver = Chrome("./browser-servers/chromedriver.exe")
    elif browser == 'ie':
        driver = Ie("./browser-servers/IEDriverServer.exe")
    else:
        print('---------------------Error----------------------')
        print('!!!!-----------Invalid Broser Option---------!!!!')
        return None
    driver.maximize_window()
    driver.implicitly_wait(30)
    if url == 'prod':
        driver.get('https://demo.actitime.com/')
    else:
        driver.get('http://localhost')
    return driver
Exemple #30
0
 def _open_browser(self, browser_name):
     """
     :return: webdriver
     """
     if browser_name == 'chrome':
         if self.options is not None:
             self.driver = Chrome(chrome_options=self.options)
         else:
             self.driver = Chrome()
     elif browser_name == 'ie':
         self.driver = Ie()
     elif browser_name == 'safari':
         self.driver = Safari()
     elif browser_name == 'edge':
         self.driver = Edge()
     elif browser_name == 'firefox':
         self.driver = Firefox()
     else:
         raise Exception('Faild input browser name')
     self.driver.get(self.base_url)
     return self.driver