def signIn(self):
        if self.params['driver'] == 'chrome':
            self.driver = webdriver.chrome()
        elif self.params['driver'] == 'firefox':
            self.driver = webdriver.Firefox()
        elif self.params['driver'] == 'edge':
            self.driver = webdriver.edge()
        elif self.params['driver'] == 'ie':
            self.driver = webdriver.ie()
        elif self.params['driver'] == 'opera':
            self.driver = webdriver.opera()
        elif self.params['driver'] == 'safari':
            self.driver = webdriver.safari()
        else:
            return False  #driver undefined
        self.initDriver = True
        self.driver.get('https://www.linkedin.com/login')

        # signin
        user_field = self.driver.find_element_by_xpath(
            "//input[@id='username']")
        user_field.send_keys(self.params['email'])
        pass_field = self.driver.find_element_by_xpath(
            "//input[@id='password']")
        pass_field.send_keys(self.params['password'])
        self.driver.find_element_by_xpath(
            "//button[@data-litms-control-urn='login-submit']").click()
        return True
Ejemplo n.º 2
0
 def __init__(self, brower):
     if brower == 'chrome' or brower == 'Chrome':
         chromDriverFilePath = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver"
         deriver = webdriver.Chrome(chromDriverFilePath)
     elif brower == 'edge' or brower == 'Edge':
         edgeFilepath = "C:\Program\Files(x86)\Microsoft\Edge\Application\msedgedriver.exe"
         deriver = webdriver.edge(edgeFilepath)
     else:
         raise NameError('只能输入Chrome,Edge')
     self.driver = deriver
Ejemplo n.º 3
0
 def driver_init(self, url, i):
     if i == 1:
         driver = webdriver.Chrome()
     elif i == 2:
         driver = webdriver.firefox()
     else:
         driver = webdriver.edge()
     driver.get(url)
     driver.maximize_window()
     return driver
Ejemplo n.º 4
0
 def __init__(self, brower="Chrome"):
     if brower == "Chrome":
         driver = webdriver.Chrome()
     elif brower == "Firefox":
         driver = webdriver.Firefox()
     elif brower == "Edge":
         driver = webdriver.edge()
     else:
         print("不支持的游览器")
     self._driver = driver
Ejemplo n.º 5
0
def setup(browser):
    if browser == 'chrome':
        driver = webdriver.Chrome(
            "C:/Users/ramya/PycharmProjects/nopcommerceApp/Drivers/chromedriver.exe"
        )
    elif browser == 'firefox':
        driver = webdriver.Firefox(
            executable_path=
            r'C:/Users/ramya/PycharmProjects/nopcommerceApp/Driver/geckodriver.exe'
        )
    else:
        driver = webdriver.edge(
            "C:/Users/ramya/1PycharmProjects/nopcommerceApp/Drivers/msedgedriver.exe"
        )
    return driver
Ejemplo n.º 6
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
Ejemplo n.º 7
0
 def start_browser(self, name='chrome'):
     try:
         if name.lower() == 'chrome':
             return webdriver.Chrome()
         elif name.lower() == 'firefox' or name.lower() == 'ff':
             return webdriver.Firefox()
         elif name.lower() == 'opera' or name.lower() == 'op':
             return webdriver.Opera()
         elif name.lower() == 'edge':
             return webdriver.edge()
         elif name.lower() == 'safari':
             return webdriver.Safari()
             pass
         elif name.lower() == 'phantomjs' or name.lower() == 'ptjs':
             pass
         else:
             print("Not found browser %s on this device" % (name))
     except Exception as msg:
         print('error occur at', str(msg))
Ejemplo n.º 8
0
    def __open_browser(self, browser, configuration_file_download):
        if browser == "chrome":
            options = webdriver.ChromeOptions()

            if configuration_file_download:
                prefs = {
                    "profile.default_content_settings.popups": 0,
                    "download.default_directory":
                    local_config.FILE_DOWNLOAD_PATH
                }
                options.add_experimental_option("prefs", prefs)
            driver = webdriver.Chrome(executable_path=file_utils.location_file(
                local_config.CHROME_DRIVER_PATH),
                                      options=options)
        elif browser == "firefox":
            options = webdriver.FirefoxOptions()
            if configuration_file_download:
                options.set_preference("browser.download.dir",
                                       local_config.FILE_DOWNLOAD_PATH)
                options.set_preference("browser.download.folderList", "2")
                options.set_preference(
                    "browser.download.manager.showWhenStarting", False)
                options.set_preference(
                    "browser.helperApps.neverAsk.saveToDisk",
                    "application/zip")
            driver = webdriver.Firefox(
                executable_path=file_utils.location_file(
                    local_config.FIREFOX_DRIVER_PATH),
                options=options)
        elif browser == "ie":
            driver = webdriver.Ie(executable_path=file_utils.location_file(
                local_config.IE_DRIVER_PATH))
        else:
            driver = webdriver.edge()
        logger.info("当前测试浏览器:{0} ,下载文件路径配置:{1}".format(
            browser, local_config.FILE_DOWNLOAD_PATH))

        return driver
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

print("Enter C for chrome , F for firefox, E for edge.\n This is Case Sensitive.")

br = input("C or F or E?: ")
path = input("Enter directory path of desired webbrowser exe file. e.g. C:/Users/hongildong/Downloads/chromedriver: ")
driver = None

if br== "C":
    driver = webdriver.Chrome(path)
if br== "F":
    driver = webdriver.Firefox(path)
if br == "E":
    driver = webdriver.edge(path)

if driver == None:
    exit()

driver.get("http://everytime.kr/login")

userid = input("ID: ")
pw = input("pw: ")
remov_num = int(input("number of posts to remove: Positive Integer\n Enter 0 to skip"))
driver.find_element_by_name(name="userid").send_keys(userid)
driver.find_element_by_name(name="password").send_keys(pw)
driver.find_element_by_name(name="password").send_keys(Keys.RETURN)

if remov_num >0:
Ejemplo n.º 10
0
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager

#driver= webdriver.firefox(executable_path="GeckoDriver.exe")
driver= webdriver.firefox(GeckoDriverManager.install())
driver.implicitly_wait(5)
driver.maximize_window()
driver.get("https://reminderbot.io/")
print("Title is "+driver.title)
driver.minimize_window()
print("Current Url is "+driver.current_url)
driver.maximize_window()
driver.quit()

#driver= webdriver.edge(executable_path="MicrosoftWebDriver.exe")
driver= webdriver.edge(EdgeChromiumDriverManager().install())
driver.implicitly_wait(5)
driver.maximize_window()
driver.get("https://reminderbot.io/")
print("Title is "+driver.title)
driver.minimize_window()
print("Current Url is "+driver.current_url)
driver.maximize_window()
driver.quit()