コード例 #1
0
def get_new_edge_driver():
    preporter.info("Spawning driver: Edge")
    driver = webdriver.Edge(EdgeDriverManager().install())
    driver.delete_all_cookies()
    driver.fullscreen_window()

    return driver
コード例 #2
0
 def __new__(cls):
     logger_name = u'{base}.{suffix}'.format(base=LOGGER_BASENAME,
                                             suffix='bootstrapper')
     logger = logging.getLogger(logger_name)
     logger.info('Starting up edge driven by selenium')
     driver = webdriver.Edge(executable_path=EdgeDriverManager().install())
     logger.info('Deleting all cookies')
     driver.delete_all_cookies()
     logger.info('Returning driver')
     return driver
コード例 #3
0
def driver(request):
    option = request.config.getoption("--browser")
    if option.lower() == "chrome":
        return webdriver.Chrome(ChromeDriverManager().install())
    elif option == "firefox":
        return webdriver.Firefox(executable_path=GeckoDriverManager().install())
    elif option == "edge":
        return webdriver.Edge(EdgeDriverManager().install())
    elif option == "ie":
        return webdriver.Ie(IEDriverManager().install())
    else:
        raise ValueError("Unrecognized browser {}".format(option))
コード例 #4
0
    def test_login_Edge(self):
        self.driver = webdriver.Edge(
            executable_path=EdgeDriverManager().install())
        self.driver.implicitly_wait(5)
        self.driver.maximize_window()
        self.driver.get("https://opensource-demo.orangehrmlive.com")
        assert self.driver.title == "OrangeHRM"

        self.driver.find_element_by_name("txtUsername").send_keys("Admin")
        self.driver.find_element_by_name("txtPassword").send_keys("admin123")
        self.driver.find_element_by_name("Submit").click()
        time.sleep(5)
        assert self.driver.title == "OrangeHRM"
        self.driver.close()
コード例 #5
0
def get_driver(browser, width, height):
    if browser == 'Chrome':
        driver = webdriver.Chrome(ChromeDriverManager().install())
    elif browser == 'Firefox':
        driver = webdriver.Firefox(GeckoDriverManager().install())
    elif browser == 'Edge':
        driver = webdriver.Edge(EdgeDriverManager().install())
    elif browser == 'IE':
        driver = webdriver.Ie(IEDriverManager().install())
    else:
        raise Exception(browser + ' is not avaliable')

    driver.set_window_size(width, height)
    return driver
コード例 #6
0
 def launch_browser_instance(self, browser_type=None):
     driver = None
     if browser_type is 'chrome':
         options = Options()
         options.add_argument("--disable-notifications")
         driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)
     elif browser_type is 'firefox':
         options = Options()
         options.add_argument("--disable-notifications")
         driver = webdriver.Firefox(executable_path=GeckoDriverManager().install(), firefox_options=options)
     elif browser_type is 'ie':
         driver = webdriver.Edge(EdgeDriverManager().install())
     driver.maximize_window()
     return driver
コード例 #7
0
 def get_webdriver_instance(self):
     if self.browser.lower() == "chrome":
         driver = webdriver.Chrome(ChromeDriverManager().install())
     elif self.browser.lower() == "firefox":
         driver = webdriver.Firefox(
             executable_path=GeckoDriverManager().install())
     elif self.browser.lower() == "edge":
         driver = webdriver.Edge(EdgeDriverManager().install())
     elif self.browser.lower() == "ie":
         driver = webdriver.Ie(IEDriverManager().install())
     else:
         driver = webdriver.Chrome(ChromeDriverManager().install())
     driver.maximize_window()
     driver.get(BASE_URL)
     return driver
コード例 #8
0
    def getbrowser(self, browsername):

        if browsername == "firefox":
            self.driver = webdriver.Firefox(
                executable_path=GeckoDriverManager().install())
        elif browsername == "chrome":
            self.driver = webdriver.Chrome(ChromeDriverManager().install())
        elif browsername == "edge":
            self.driver = webdriver.Edge(EdgeDriverManager().install())
        elif browsername == "ie":
            self.driver = webdriver.Ie(IEDriverManager().install())
        else:
            self.driver = webdriver.Chrome(ChromeDriverManager().install())

        self.driver.maximize_window()
        self.driver.implicitly_wait(60)
        return self.driver
コード例 #9
0
def driver(request):
    """Open browser driver settings"""
    option = request.config.getoption("--browser")
    if option.lower() == "chrome":
        driver = webdriver.Chrome(ChromeDriverManager().install())
    elif option == "firefox":
        driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
    elif option == "edge":
        driver = webdriver.Edge(EdgeDriverManager().install())
    elif option == "ie":
        driver = webdriver.Ie(IEDriverManager().install())
    else:
        raise ValueError("Unrecognized browser {}".format(option))
    driver.implicitly_wait(5)
    driver.maximize_window()
    yield driver
    driver.quit()
コード例 #10
0
    def testMethod(self):
        # Initiate the driver instance
        driver = webdriver.Edge(executable_path=EdgeDriverManager().install())

        # Open the desired URL
        driver.get("http://www.google.com")

        # Maximize the browser window
        driver.maximize_window()

        time.sleep(5)  # Let the user actually see something!

        # Close the browser
        driver.close()

        # Close the webdriver instance
        driver.quit()
コード例 #11
0
ファイル: conftest.py プロジェクト: satee143/zoopla.co.uk
def Setup(request):
    browser = request.config.getoption('--browser')
    if browser == 'chrome':
        driver = webdriver.Chrome(ChromeDriverManager().install())
    elif browser == 'firefox':
        driver = webdriver.Firefox(
            executable_path=GeckoDriverManager().install())
    elif browser == 'edge':
        driver = webdriver.Edge(EdgeDriverManager().install())
    elif browser == 'ie' or 'internet explorer':
        driver = webdriver.Ie(executable_path=IEDriverManager().install())

    request.cls.driver = driver
    driver.maximize_window()
    driver.implicitly_wait(2)
    yield
    driver.close()
    driver.quit()
コード例 #12
0
def Browser_setup(request):
    browser = request.config.getoption('--browser')
    if browser.lower() == 'chrome':
        driver = webdriver.Chrome(ChromeDriverManager().install())

    elif browser.lower() == 'firefox':
        driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

    elif browser.lower() == 'ie':
        driver = webdriver.Ie(IEDriverManager().install())
        

    elif browser.lower() == 'edge':
        driver=webdriver.Edge(EdgeDriverManager().install())
        

    request.cls.driver = driver
    driver.maximize_window()
    driver.implicitly_wait(15)
    driver.get(util.URL)
    yield
    driver.close()
    driver.quit()
コード例 #13
0
ファイル: environment.py プロジェクト: DenisKolesnik/tanabata
def before_scenario(context, scenario):
    if 'browser' in context.config.userdata.keys():
        if context.config.userdata['browser'] is None:
            browser = 'chrome'
        else:
            browser = context.config.userdata['browser']
    else:
        browser = 'chrome'

    if browser == 'chrome':
        context.browser = webdriver.Chrome(ChromeDriverManager().install())
    elif browser == 'firefox':
        context.browser = webdriver.Firefox(
            executable_path=GeckoDriverManager().install())
    elif browser == 'edge':
        context.browser = webdriver.Edge(EdgeDriverManager().install())
    elif browser == 'safari':
        context.browser = webdriver.Safari()
    elif browser == 'ie':
        context.browser = webdriver.Ie(IEDriverManager().install())
    elif browser == 'opera':
        context.browser = webdriver.Opera()
    elif browser == 'phantomjs':
        if 'docker' in context.config.userdata.keys():
            context.browser = webdriver.Remote(
                command_executor='http://phantomjs:8910',
                desired_capabilities=DesiredCapabilities.PHANTOMJS)
        else:
            context.browser = webdriver.PhantomJS(
                PhantomJsDriverManager().install())
    else:
        print("Browser you entered:", browser, "is invalid value")

    context.browser.implicitly_wait(WAIT)
    context.browser.maximize_window()

    context.base_url = context.config.userdata.get('instance_url')
コード例 #14
0
ファイル: webdriverfactory.py プロジェクト: nadim1975/Gportal
    def getWebDriverInstance(self):
        """
       Get WebDriver Instance based on the browser configuration
       For Bamboo integration need to use the webdriver manager to install the webdrivers on runtime
       instead of using the path on local machine:
       https://github.com/SergeyPirogov/webdriver_manager

        Returns:
            'WebDriver Instance'
        """
        """"
        # Location where I save the drivers on my local machine
        chromeDriverLocation = "C:\\Users\\nhussein\\PycharmProjects\\chromedriver.exe"
        ffDriverLocation = "C:\\Users\\nhussein\\PycharmProjects\\geckodriver.exe"
        ieDriverLocation = "C:\\Users\\nhussein\\PycharmProjects\\IEDriverServer.exe"
        """

        if self.browser == "ie":
            # Set ie driver
            #os.environ["webdriver.ie.driver"] = ieDriverLocation
            #driver = webdriver.Ie(ieDriverLocation)
            #install IE driver to default path C:\Users\nhussein\.wdm\IEDriverServer\3.141.5\Win32
            driver = webdriver.Ie(IEDriverManager(os_type="win32").install())

        elif self.browser == "edge":
            #default installation folder C:\Users\nhussein\.wdm\MicrosoftWebDriver\latest\win
            driver = webdriver.Edge(EdgeDriverManager().install())

        elif self.browser == "ff":
            #driver = webdriver.Firefox()
            # default installation path C:\Users\nhussein\.wdm\geckodriver\v0.23.0\win64
            driver = webdriver.Firefox(
                executable_path=GeckoDriverManager().install())

        elif self.browser == "ffdocker":
            #driver = webdriver.Firefox()
            capabilities = DesiredCapabilities.FIREFOX.copy()
            driver = webdriver.Remote("http://127.0.0.1:4446/wd/hub",
                                      capabilities)

        elif self.browser == "ffheadless":
            ffDriverLocation = "C:\TEMP\geckodriver.exe"
            webdriver.Firefox(executable_path=GeckoDriverManager().install(
                path="C:\TEMP"))
            options = ff_options()
            options.headless = True
            driver = webdriver.Firefox(options=options,
                                       executable_path=ffDriverLocation)

        elif self.browser == "chrome":
            # Set chrome driver
            #os.environ["webdriver.chrome.driver"] = chromeDriverLocation
            #driver = webdriver.Chrome(chromeDriverLocation)
            driver = webdriver.Chrome(ChromeDriverManager().install())
            driver.set_window_size(1920, 1080)

        elif self.browser == "chromedocker":
            # Set chrome driver
            #driverLocation = "C:\\Users\\nhussein\\PycharmProjects\\selenium_workspace\\chromedriver.exe"
            #os.environ["webdriver.chrome.driver"] = chromeDriverLocation
            ####### THIS WILL USE DOCKER CONTAINER AND LAUNCH THE SCRIPT ON VNC ##########################3##########
            capabilities = DesiredCapabilities.CHROME.copy()
            #capabilities['platform'] = "WINDOWS"
            #capabilities['version'] = "10"
            capabilities['takesScreenshot'] = True
            driver = webdriver.Remote("http://127.0.0.1:4446/wd/hub",
                                      capabilities)
            driver.set_window_size(1920, 1080)

        elif self.browser == "chromeheadless":
            chromeDriverLocation = "C:\TEMP\chromedriver.exe"
            webdriver.Chrome(ChromeDriverManager().install(path="C:\TEMP"))

            # To use the default driver installation path comment out the above 2 lines and uncomment the below 2 lines

            #webdriver.Chrome(ChromeDriverManager().install())
            #chromeDriverLocation = str(self.getHomeDirectory())+"\.wdm\chromedriver\\2.45\win32\chromedriver.exe"

            options = chrome_options()
            options.headless = True
            driver = webdriver.Chrome(chromeDriverLocation,
                                      chrome_options=options)

        elif self.browser == "mobile":
            # Select which device you want to emulate by uncommenting it
            # More information at: https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation
            mobile_emulation = {
                "deviceName": "iPhone 6/7/8"
                # "deviceName": "iPhone 6/7/8 Plus"
                # "deviceName": "iPhone X"
                # "deviceName": "iPad"
                # "deviceName": "iPad Mini"
                # "deviceName": "iPad Pro"
                # "deviceName": "Nexus 10"
                # "deviceName": "Galaxy S III"
                # "deviceName": "Galaxy Note 3"
                # Or specify a specific build using the following two arguments
                # "deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 },
                # "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19"
            }
            # Define a variable to hold all the configurations we want
            options = chrome_options()
            # Add the mobile emulation to the chrome options variable
            options.add_experimental_option("mobileEmulation",
                                            mobile_emulation)
            # Create driver, pass it the path to the chromedriver file and the special configurations you want to run
            chromeDriverLocation = "C:\TEMP\chromedriver.exe"
            webdriver.Chrome(ChromeDriverManager().install(path="C:\TEMP"))
            driver = webdriver.Chrome(chromeDriverLocation,
                                      chrome_options=options)

        else:
            #driver = webdriver.Firefox()
            driver = webdriver.Firefox(
                executable_path=GeckoDriverManager().install())

        # Setting Driver Implicit Time out for An Element
        driver.implicitly_wait(3)
        # Maximize the window
        driver.maximize_window()

        #selecting the URL based on the environment param
        #env = self.environment.lower()
        if self.environment == 'qa':
            baseURL = "https://portal.qa.aws.wfscorp.com/"
        elif self.environment == 'test':
            baseURL = "https://portal.test.aws.wfscorp.com/"
        elif self.environment == 'dev':
            baseURL = "https://portal.dev.aws.wfscorp.com/"
        else:
            baseURL = "https://portal.qa.aws.wfscorp.com/"

        # Loading browser with App URL

        driver.get(baseURL)
        return driver
コード例 #15
0
ファイル: app.py プロジェクト: shahlin/whatsapp-autoresponder
# Get --browser command line argument value or assign a default
selected_browser = args['browser']

try:
    # Support for Chrome
    if (selected_browser is None) or (selected_browser == 'chrome'):
        browser = webdriver.Chrome(ChromeDriverManager().install())

    # Support for Firefox
    elif selected_browser.lower() == 'firefox':
        browser = webdriver.Firefox(
            executable_path=GeckoDriverManager().install())

    # Support for Microsoft Edge
    elif selected_browser.lower() == 'edge':
        browser = webdriver.Edge(EdgeDriverManager().install())

    # Support for Microsoft Internet Explorer
    elif selected_browser.lower() == 'ie':
        browser = webdriver.Ie(IEDriverManager().install())

    else:
        exit("Invalid choice. Quitting now...")

except:
    exit(
        'Error! Make sure you\'re selecting the right browser! Quitting now...'
    )

###############################################################################
#                           AUTO RESPONSE LOGIC                               #
コード例 #16
0
def test_edge_manager_with_selenium_cache(path):
    driver_path = EdgeDriverManager().install(path)
    dr = webdriver.Edge(driver_path)
    dr.quit()
コード例 #17
0
def test_edge_manager_with_selenium(path):
    delete_old_install(path)
    driver_path = EdgeDriverManager().install(path)
    dr = webdriver.Edge(driver_path)
    dr.quit()
コード例 #18
0
    def getbrowser(self, browsername):

        mobile_emulation = {
            # "deviceName": "Apple iPhone 3GS"
            # "deviceName": "Apple iPhone 4"
            # "deviceName": "Apple iPhone 5"
            # "deviceName": "Apple iPhone 6"
            # "deviceName": "Apple iPhone 6 Plus"
            # "deviceName": "BlackBerry Z10"
            # "deviceName": "BlackBerry Z30"
            # "deviceName": "Google Nexus 4"
            "deviceName": "Galaxy S5"
            # "deviceName": "Google Nexus S"
            # "deviceName": "HTC Evo, Touch HD, Desire HD, Desire"
            # "deviceName": "HTC One X, EVO LTE"
            # "deviceName": "HTC Sensation, Evo 3D"
            # "deviceName": "LG Optimus 2X, Optimus 3D, Optimus Black"
            # "deviceName": "LG Optimus G"
            # "deviceName": "LG Optimus LTE, Optimus 4X HD"
            # "deviceName": "LG Optimus One"
            # "deviceName": "Motorola Defy, Droid, Droid X, Milestone"
            # "deviceName": "Motorola Droid 3, Droid 4, Droid Razr, Atrix 4G, Atrix 2"
            # "deviceName": "Motorola Droid Razr HD"
            # "deviceName": "Nokia C5, C6, C7, N97, N8, X7"
            # "deviceName": "Nokia Lumia 7X0, Lumia 8XX, Lumia 900, N800, N810, N900"
            # "deviceName": "Samsung Galaxy Note 3"
            # "deviceName": "Samsung Galaxy Note II"
            # "deviceName": "Samsung Galaxy Note"
            # "deviceName": "Samsung Galaxy S III, Galaxy Nexus"
            # "deviceName": "Samsung Galaxy S, S II, W"
            # "deviceName": "Samsung Galaxy S4"
            # "deviceName": "Sony Xperia S, Ion"
            # "deviceName": "Sony Xperia Sola, U"
            # "deviceName": "Sony Xperia Z, Z1"
            # "deviceName": "Amazon Kindle Fire HDX 7″"
            # "deviceName": "Amazon Kindle Fire HDX 8.9″"
            # "deviceName": "Amazon Kindle Fire (First Generation)"
            # "deviceName": "Apple iPad 1 / 2 / iPad Mini"
            # "deviceName": "Apple iPad 3 / 4"
            # "deviceName": "BlackBerry PlayBook"
            # "deviceName": "Google Nexus 10"
            # "deviceName": "Google Nexus 7 2"
            # "deviceName": "Google Nexus 7"
            # "deviceName": "Motorola Xoom, Xyboard"
            # "deviceName": "Samsung Galaxy Tab 7.7, 8.9, 10.1"
            # "deviceName": "Samsung Galaxy Tab"
            # "deviceName": "Notebook with touch"

            # Or specify a specific build using the following two arguments
            # "deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 },
            # "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19" }
        }
        # Define a variable to hold all the configurations we want
        chrome_options = webdriver.ChromeOptions()
        # Add the mobile emulation to the chrome options variable
        chrome_options.add_experimental_option("mobileEmulation",
                                               mobile_emulation)

        if browsername == "firefox":
            self.driver = webdriver.Firefox(
                executable_path=GeckoDriverManager().install(),
                options=chrome_options)
        elif browsername == "chrome":
            self.driver = webdriver.Chrome(ChromeDriverManager().install(),
                                           options=chrome_options)
        elif browsername == "edge":
            self.driver = webdriver.Edge(EdgeDriverManager().install(),
                                         options=chrome_options)
        elif browsername == "ie":
            self.driver = webdriver.Ie(IEDriverManager().install(),
                                       options=chrome_options)
        else:
            self.driver = webdriver.Chrome(ChromeDriverManager().install(),
                                           options=chrome_options)

        # self.driver.maximize_window()
        self.driver.implicitly_wait(60)
        return self.driver
コード例 #19
0
#Setup
# pip install webdriver_manager
# pip install selenium

from webdriver_manager.microsoft import EdgeDriverManager
from selenium import webdriver

driver = webdriver.Edge(executable_path=EdgeDriverManager().install())
driver.get("http://www.google.com/")
print(driver.title)
driver.quit()