当前位置: 首页>>代码示例>>Python>>正文


Python Firefox.quit方法代码示例

本文整理汇总了Python中selenium.webdriver.Firefox.quit方法的典型用法代码示例。如果您正苦于以下问题:Python Firefox.quit方法的具体用法?Python Firefox.quit怎么用?Python Firefox.quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.Firefox的用法示例。


在下文中一共展示了Firefox.quit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AcceptanceTest

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
class AcceptanceTest(StaticLiveServerTestCase):
    def setUp(self):
        options = Options()
        options.headless = True
        self.driver = Firefox(options=options)

    def tearDown(self):
        self.driver.quit()

    def test_two_inputs(self):
        driver = self.driver
        driver.get('{live_server_url}/two-field-test/'.format(
            live_server_url=self.live_server_url
        ))
        WebDriverWait(driver, 5).until(
            wait_for_utils_script()
        )
        inputs = driver.find_elements_by_css_selector('input.intl-tel-input')
        inputs[0].send_keys('555-5555')
        inputs[1].send_keys('555-4444')
        inputs[1].send_keys(Keys.RETURN)
        WebDriverWait(driver, 5).until(
            EC.presence_of_element_located((By.ID, 'success-text'))
        )

        self.assertIn('Form is valid', driver.page_source)
开发者ID:benmurden,项目名称:django-intl-tel-input,代码行数:28,代码来源:tests.py

示例2: setup_browser

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def setup_browser():
    browser = Firefox()
    browser.set_window_size(1280, 800)
    # WORKAROUND for recordmydesktop bug
    browser.set_window_position(10, 10)
    yield browser
    browser.quit()
开发者ID:rshk,项目名称:autoscreencast-poc,代码行数:9,代码来源:build.py

示例3: driver

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def driver(capabilities):
    options = Options()
    driver = Firefox(
        capabilities=capabilities,
        firefox_options=options)
    yield driver
    driver.quit()
开发者ID:zhjwpku,项目名称:selenium,代码行数:9,代码来源:mn_options_tests.py

示例4: print_prices

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def print_prices():
    driver = Firefox()
    driver.get("https://cars.mail.ru/sale/msk/all/?order=price&dir=asc")
    elements = [None] * 20
    for i in range(0, 20):
        print 'finding by xpath', i
        elements[i] = WebDriverWait(driver, 10).until(
            lambda d: d.find_element_by_xpath('(//span[@class="offer-card__price__value"])[%d]' % (i + 1,)))
    for i in range(0, 20):
        print 'text', elements[i].text
    driver.quit()
开发者ID:KhasanovBI,项目名称:home-assignment-4,代码行数:13,代码来源:get_prices_slow.py

示例5: test_that_we_can_accept_a_profile

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def test_that_we_can_accept_a_profile(capabilities, webserver):
    profile1 = FirefoxProfile()
    profile1.set_preference("browser.startup.homepage_override.mstone", "")
    profile1.set_preference("startup.homepage_welcome_url", webserver.where_is('simpleTest.html'))
    profile1.update_preferences()

    profile2 = FirefoxProfile(profile1.path)
    driver = Firefox(
        capabilities=capabilities,
        firefox_profile=profile2)
    title = driver.title
    driver.quit()
    assert "Hello WebDriver" == title
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:15,代码来源:ff_profile_tests.py

示例6: test_add_extension_legacy_extension

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def test_add_extension_legacy_extension(capabilities, webserver):
    current_directory = os.path.dirname(os.path.realpath(__file__))
    root_directory = os.path.join(current_directory, '..', '..', '..', '..', '..')
    extension_path = os.path.join(root_directory, 'third_party', 'firebug', 'firebug-1.5.0-fx.xpi')

    profile = FirefoxProfile()
    profile.add_extension(extension_path)

    driver = Firefox(capabilities=capabilities, firefox_profile=profile)
    profile_path = driver.firefox_profile.path
    extension_path_in_profile = os.path.join(profile_path, 'extensions', '[email protected]')
    assert os.path.exists(extension_path_in_profile)
    driver.quit()
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:15,代码来源:ff_profile_tests.py

示例7: test_add_extension_web_extension_without_id

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def test_add_extension_web_extension_without_id(capabilities, webserver):
    current_directory = os.path.dirname(os.path.realpath(__file__))
    root_directory = os.path.join(current_directory, '..', '..', '..', '..', '..')
    extension_path = os.path.join(root_directory, 'third_party', 'firebug', 'mooltipass-1.1.87.xpi')

    profile = FirefoxProfile()
    profile.add_extension(extension_path)

    driver = Firefox(capabilities=capabilities, firefox_profile=profile)
    profile_path = driver.firefox_profile.path
    extension_path_in_profile = os.path.join(profile_path, 'extensions', '[email protected]')
    assert os.path.exists(extension_path_in_profile)
    driver.quit()
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:15,代码来源:ff_profile_tests.py

示例8: load_search_results

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def load_search_results(context_id=None):
    flashcards = load_flashcards_data()
    if context_id is not None:
        flashcards = flashcards[flashcards['context_id'] == context_id]
    to_process = list(flashcards[['term_id', 'term_name']].drop_duplicates().dropna(subset=['term_name']).values)
    random.shuffle(to_process)
    global BROWSER
    BROWSER = Firefox()
    try:
        result = []
        for term_id, term_name in progress.bar(to_process):
            result.append(_load_search_results_apply(term_id, term_name))
        return pandas.DataFrame(result)
    finally:
        BROWSER.quit()
开发者ID:papousek,项目名称:analysis,代码行数:17,代码来源:raw.py

示例9: test_add_extension_web_extension_with_id

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def test_add_extension_web_extension_with_id(capabilities, webserver):
    current_directory = os.path.dirname(os.path.realpath(__file__))
    root_directory = os.path.join(current_directory, '..', '..', '..', '..', '..')
    # TODO: This file should probably live in a common directory.
    extension_path = os.path.join(root_directory, 'javascript', 'node', 'selenium-webdriver',
                                  'lib', 'test', 'data', 'firefox', 'webextension.xpi')

    profile = FirefoxProfile()
    profile.add_extension(extension_path)

    driver = Firefox(capabilities=capabilities, firefox_profile=profile)
    profile_path = driver.firefox_profile.path
    extension_path_in_profile = os.path.join(profile_path, 'extensions', '[email protected]')
    assert os.path.exists(extension_path_in_profile)
    driver.get(webserver.where_is('simpleTest.html'))
    driver.find_element_by_id('webextensions-selenium-example')
    driver.quit()
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:19,代码来源:ff_profile_tests.py

示例10: driver

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def driver(request):
    browser = request.param
    if browser == 'firefox':
        driver = Firefox()
    elif browser == 'chrome':
        driver = Chrome()
    else:
        raise ValueError("Unknown browser '{}'".format(browser))
    request.addfinalizer(lambda: driver.quit())
    return driver
开发者ID:ivan-krukov,项目名称:pytest-selenium,代码行数:12,代码来源:test_fixturedemo3.py

示例11: run

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
 def run(self):
         self.__display = Display(visible=0, size=(800, 600))
         self.__display.start()
         page_source = ""
         try :
             # use firefox to get page with javascript generated content
             with closing(Firefox()) as browser:
                 browser = Firefox()
                 browser.get(self.__url)
                 # wait for the page to load
                 WebDriverWait(browser, timeout=20)#.until(
                 #lambda x: x.find_element_by_id('someId_that_must_be_on_new_page'))
                 # store it to string variable
                 page_source = browser.page_source
                 self.distribPageGenerated.sig.emit(page_source)
                 self.__display.stop()
                 browser.quit()
                 
         except AttributeError:
             print "browser quit AttributeError issue... don't care, go on !"
             pass
开发者ID:poupou14,项目名称:CombinoGen,代码行数:23,代码来源:GridRequestor.py

示例12: process2

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def process2(url, name, parser):
    # They have JS in the page...
    print("Get Page for", name)
    browser = Firefox()
    browser.get(url)
    h_test = browser.page_source
    browser.quit()
    print("Parse")
    l_edite = parser.get_thesis_list(h_test)
    try:
        with open(name + ".pickle", "rb") as f_open:
            previous_thesis = pickle.load(f_open)
    except FileNotFoundError:
        previous_thesis = set()
    with open(name + ".pickle", "wb") as f_open:
        pickle.dump(previous_thesis.union(l_edite), f_open)
    for thesis in l_edite - previous_thesis:
        print(thesis)
    print(len(l_edite - previous_thesis), "new thesis proposal for", name)
    print(len(previous_thesis), "previously")
    print(len(l_edite), "found")
开发者ID:Aunsiels,项目名称:Scripts,代码行数:23,代码来源:main.py

示例13: Scraper

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
class Scraper(object):
	def __init__(self, url):
		self.url = url
		self.browser = None
		self.display = Display(
			visible=0,
			size=(800, 600)
		)

	def open(self):
		self.display.start()
		self.browser = Firefox()

	def close(self):
		self.browser.quit()
		self.display.stop()

	def scrape(self):
		self.browser.get(self.url)
		self.browser.delete_all_cookies()
		return self.browser.page_source
开发者ID:Mattstah,项目名称:ls_scrape,代码行数:23,代码来源:scraper.py

示例14: DIMA_WIN

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
class DIMA_WIN():
    ROOT_URL = "http://detki.co.il/photo/photokonkurs1.html/"
    VOIT_URL = "http://detki.co.il/photo/photokonkurs1.html?vote=5&star_id=30"
    CSS = "/html/body"

    def __init__(self):
        try:
            self.driver = Firefox(timeout=10)

            # self.driver.get(self.ROOT_URL)
            # alert = self.driver.switch_to_alert()
            # WebDriverWait(self.driver, 15)
        except (Exception, ) as e:
            print e
            self.driver.quit()

    def wait(self, issue, search_type='css'):
        try:
            if search_type == 'css':
                WebDriverWait(self.driver, timeout=60).until(
                    lambda x: x.find_element(By.XPATH, issue))
            elif search_type == 'id':
                WebDriverWait(self.driver, timeout=60).until(
                    lambda x: x.find_element(By.ID, issue))
        except (TimeoutException, Exception) as e:
            print e
            self.driver.quit()

    def start(self):
        try:
            with timeout(10):  # AVOID AUTH WINDOW
                self.driver.get(self.ROOT_URL)

        except (Exception,) as e:
            print e
            self.driver.quit()
    def voit(self):
        try:
            with timeout(120):  # AVOID AUTH WINDOW
                self.driver.get(self.ROOT_URL)
                WebDriverWait(self.driver, 20)
                actions = ActionChains(self.driver)
                # li = self.driver.find_element_by_xpath('//*[@id="content"]/div/div[1]/div[1]/div[1]/ul/li[38]/div/div[1]/ul/li[6]/a')
                lli = self.driver.find_element_by_css_selector('#content > div > div.large-12.columns > div:nth-child(2) > div.large-8.columns > ul > li:nth-child(38) > div > div.large-7.columns > ul > li:nth-child(6) > a')
                actions.click(lli)
                print "clicked"
        except (Exception,) as e:
            print e
        finally:
            self.driver.quit()
开发者ID:compfaculty,项目名称:TeachMePython,代码行数:52,代码来源:dima_selenium.py

示例15: login

# 需要导入模块: from selenium.webdriver import Firefox [as 别名]
# 或者: from selenium.webdriver.Firefox import quit [as 别名]
def login(username, password):
  """Login into website, return cookies, api and sso token using geckodriver/firefox headless"""

  display = Display(visible=0, size=(800, 600))
  display.start()
#  options = Options()
#  options.add_argument('-headless')
#  driver = Firefox(executable_path='/usr/local/bin/geckodriver', firefox_options=options)
  driver = Firefox()
  wait = WebDriverWait(driver, timeout=10)

  driver.get(url)
  time.sleep(10)

  username_field = driver.find_element_by_name("emailOrPcrNumber")
#  There are multiple entries with the name pin, use the xpath instead even though it is more error prone
#  password_field = driver.find_element_by_name("pin")
  password_field = driver.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/div[1]/div[2]/form/div/div[1]/div[2]/input')

  username_field.clear()
  username_field.send_keys(username)

  password_field.clear()
  password_field.send_keys(password)

  time.sleep(2)
  driver.find_element_by_id("tpiSubmitButton").click()

  time.sleep(3)
  cookies = driver.get_cookies()
  for cookie in cookies:
    if cookie['name'] == 'X-IHG-SSO-TOKEN':
      sso_token = cookie['value']
  api_key = driver.execute_script('return AppConfig.featureToggle.apiKey')

  driver.get('https://apis.ihg.com')
  cookies.extend(driver.get_cookies())
  driver.quit()
  display.stop()
  return api_key, sso_token, cookies
开发者ID:ixs,项目名称:traveltools,代码行数:42,代码来源:ihg-account-data.py


注:本文中的selenium.webdriver.Firefox.quit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。