Exemplo n.º 1
0
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
Exemplo n.º 2
0
 def setup(self):
     self.driver = Ie()
     self.driver.get('https://www09.rminteract.com/')
     self.status = {
         "left": [],
         "duplicate": [],
         "RD1066C": [],
     }
class FrameworkTests(unittest.TestCase):
    def __init__(self,test,browser_name,url,test_data=None):
        super(FrameworkTests,self).__init__(test)
        self.test=test
        self.browser_name=browser_name
        self.url=url
        self.driver=None
        if self.browser_name=='firefox':
            ffp = FirefoxProfile()
            ffp.update_preferences()
            self.driver = Firefox(firefox_profile=ffp)
        elif self.browser_name=='chrome':
            chromedriver = load_browser_driver("chromedriver")
            os.environ["webdriver.chrome.driver"] = chromedriver
            self.driver=Chrome(chromedriver)
        elif self.browser_name=='ie':
            iedriver = load_browser_driver("IEDriverServer")
            os.environ["webdriver.ie.driver"] = iedriver
            self.driver=Ie(iedriver)
        self.verification = []
        self.verification.append("Test %s on browser %s" %(self.test,self.browser_name))
        self.test_data=test_data
        self.errors=[]
        
    def setUp(self):
        """
            set up data used in the tests.
            setUp is called before each test function execution.
        """
        self.driver.get(self.url)
        time.sleep(5)
    
    def tearDown(self):
        """
            tearDown is called after all other test methods have been invoked.
        """
        if self.driver:
            try:
                time.sleep(2)
                self.driver.quit()
            except:
                print traceback.format_exc()
        for item in self.verification:
            logging.info(item)
        for err in self.errors:
            self.fail(err)
            logging.error(item)
            
    def test_recordplayback(self):
        try:
            self.verification.append('Test record and playback')
            from linearframework.recordtests import show_answer_record
            actual_answer=show_answer_record(self.driver)
            self.assertEqual(actual_answer, EXPECTED_ANSWER, 'Actual answer incorrect:%s.Expected answer is:%s' %(actual_answer,EXPECTED_ANSWER))
        except Exception,ex:
            raise Exception('Test record playback failed with Exception:%s' %ex)
Exemplo n.º 4
0
def test_we_can_launch_multiple_ie_instances():
    driver1 = Ie()
    driver2 = Ie()
    driver3 = Ie()
    driver1.quit()
    driver2.quit()
    driver3.quit()
Exemplo n.º 5
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()
Exemplo n.º 6
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)
Exemplo n.º 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()
Exemplo n.º 8
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)
Exemplo n.º 9
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
Exemplo n.º 10
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()
Exemplo n.º 11
0
 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)
Exemplo n.º 12
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()
Exemplo n.º 13
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)
Exemplo n.º 14
0
 def create(self):
     '''
     Create a new driver.
     '''
     return Ie(**filternone(
         port=self.get_port(),
         timeout=self.get_timeout(),
     ))
Exemplo n.º 15
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)
Exemplo n.º 16
0
 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 __init__(self,test,browser_name,url,test_data=None):
     super(FrameworkTests,self).__init__(test)
     self.test=test
     self.browser_name=browser_name
     self.url=url
     self.driver=None
     if self.browser_name=='firefox':
         ffp = FirefoxProfile()
         ffp.update_preferences()
         self.driver = Firefox(firefox_profile=ffp)
     elif self.browser_name=='chrome':
         chromedriver = load_browser_driver("chromedriver")
         os.environ["webdriver.chrome.driver"] = chromedriver
         self.driver=Chrome(chromedriver)
     elif self.browser_name=='ie':
         iedriver = load_browser_driver("IEDriverServer")
         os.environ["webdriver.ie.driver"] = iedriver
         self.driver=Ie(iedriver)
     self.verification = []
     self.verification.append("Test %s on browser %s" %(self.test,self.browser_name))
     self.test_data=test_data
     self.errors=[]
Exemplo n.º 18
0
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')
Exemplo n.º 19
0
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')
Exemplo n.º 20
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
Exemplo n.º 21
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
Exemplo n.º 22
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
Exemplo n.º 23
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
Exemplo n.º 24
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/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
Exemplo n.º 25
0
def extract_citation_for_publication(link):
    """
    this function craws the list of articles from a given link. If it has next page, it will continue to it until there is none
    @param[in]      profile_url     the link of google scholar profile you want to crawl
    @return         the list of articles as a list where each entry is dictionary    
    """
    browser=Browser()
    citation={}
    # go the citation view
    # as the page is written is javascript, we are not able to get its content via urllib2
    # intead we will use Selenium to simulate a web browser to render the page
    # req=urllib2.Request(publication[k]['link'], headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0'})
    # p=urllib2.urlopen(req)
    # sub_soup=BeautifulSoup(p.readlines()[0], 'html.parser')
    # s=sub_soup.find(id='gs_ccl')
    browser.get(link)
    while True:
        citation_root=browser.find_element_by_id('gs_ccl')
        citation_list=citation_root.find_elements_by_class_name('gs_r')
        for citation_item in citation_list:
            # title
            title=citation_item.find_element_by_class_name('gs_rt').text
            # try to get the downloading link, if there is one
            try:
                link=citation_item.find_element_by_id('gs_ggsW2')
                link=link.find_element_by_link_text(link.text).get_attribute('href')
            except:
                link=None
            # author
            author_line=citation_item.find_element_by_class_name('gs_a')
            author_name=author_line.text.split(', ')
            author={}
            # for each of the author, find its link if its exits
            for a in author_name:
                try:
                    print '.',
                    # there is a google scholar profile with author
                    item=author_line.find_element_by_link_text(a)
                    author[a]=item.get_attribute('href')
                except:
                    # there is not such profile
                    author[a]=None
            # we can also press the cite button to get the detailed citation information, skipped here
            citation[title]={'link':link, 'author': author}
        # go to next page, if there is one
        if not next_page(browser):
            break
    # close
    browser.close()
    return citation
Exemplo n.º 26
0
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
Exemplo n.º 27
0
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
Exemplo n.º 28
0
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
Exemplo n.º 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('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
Exemplo n.º 30
0
def get_browser_instance():

    browser_info= pytest.config.option.browser
    test_url_info= pytest.config.option.url
    if browser_info == "chrome":
        driver=Chrome("./Browser-Servers/chromedriver.exe")
    elif browser_info == "Firefox":
        driver=Firefox("./Browser-Servers/geckodriver.exe")
    elif browser_info == "Ie":
        driver=Ie("./Browser-Servers/IEDriverServer.exe")
    else:
        print("!!!!!!Invalid Browser option please check --browser parameter from CMD!!!!!!!!")
        return None

    driver.maximize_window()
    driver.implicitly_wait(30)
    if test_url_info == 'test':
        driver.get("https://tot.efi.com")
    elif test_url_info == 'prod':
        driver.get("https:// demo.actitime.com")
    return driver
Exemplo n.º 31
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()
Exemplo n.º 32
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
Exemplo n.º 33
0
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!")
Exemplo n.º 34
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
Exemplo n.º 35
0
def extract_publication(profile_url, verbose=verbose_citation_list):
    """
    this function crawl the publication list from the google scholar profile
    @param[in]      profile_url     the link of google scholar profile you want to crawl
    @param[in]      verbose         the level of information you want to scrawl. By default, we will scraw the detailed citation list for each of your publicaiton
    @return         the list of pulication as a list, where each entry is a dictionary
    """
    # scholar's artical list
    browser=Browser()
    browser.get(profile_url)
    publication={}
    while True:
        publication_list=browser.find_elements_by_class_name('gsc_a_tr')
        for publication_item in publication_list:
            title=publication_item.find_element_by_class_name('gsc_a_at').text
            print title,
            author=publication_item.find_elements_by_class_name('gs_gray')[0].text.split(', ')
            vendor=publication_item.find_elements_by_class_name('gs_gray')[1].text
            try:
                citation=int(publication_item.find_element_by_class_name('gsc_a_ac').text)
                link=publication_item.find_element_by_class_name('gsc_a_ac').get_attribute('href')
            except:
                citation=0
                link=None
            try:
                year=int(publication_item.find_element_by_class_name('gsc_a_h').text)
            except:
                year=None
            if citation>0 and verbose>=verbose_citation_list:
                print 'and its citation list',
                cited_by=extract_citation_for_publication(link)
            else:
                cited_by=None    
            print 'finished'
            publication[title]={'link':link,'author':author,'vendor':vendor,'citation':citation, 'cited by': cited_by, 'year':year}
        if not next_page(browser):
            break
    browser.close()
    return publication
Exemplo n.º 36
0
def test_launch_and_close_browser():
    driver = Ie()
    driver.quit()
Exemplo n.º 37
0
def test_launch_ie_do_not_affect_default_capabilities():
    expected = DesiredCapabilities.INTERNETEXPLORER.copy()
    driver = Ie()
    actual = DesiredCapabilities.INTERNETEXPLORER.copy()
    driver.quit()
    assert actual == expected