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


Python SimpleWebServer.where_is方法代码示例

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


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

示例1: setup_method

# 需要导入模块: from selenium.test.selenium.webdriver.common.webserver import SimpleWebServer [as 别名]
# 或者: from selenium.test.selenium.webdriver.common.webserver.SimpleWebServer import where_is [as 别名]
class TestOptions:

    def setup_method(self, method):
        self.webserver = SimpleWebServer()
        self.webserver.start()

    def test_we_can_pass_options(self):
        capabilities = {'marionette': True}
        options = Options()
        self.driver = webdriver.Firefox(
            capabilities=capabilities,
            firefox_options=options)
        self.driver.get(self.webserver.where_is('formPage.html'))
        self.driver.find_element_by_id("cheese")

    def teardown_method(self, method):
        try:
            self.driver.quit()
        except:
            pass  # Don't care since we may have killed the browser above
        self.webserver.stop()
开发者ID:AkosLukacs,项目名称:selenium,代码行数:23,代码来源:mn_options_tests.py

示例2: setup_method

# 需要导入模块: from selenium.test.selenium.webdriver.common.webserver import SimpleWebServer [as 别名]
# 或者: from selenium.test.selenium.webdriver.common.webserver.SimpleWebServer import where_is [as 别名]
class TestFirefoxProfile:

    def setup_method(self, method):
        self.driver = webdriver.Firefox()
        self.webserver = SimpleWebServer()
        self.webserver.start()

    def test_that_we_can_accept_a_profile(self):
        profile1 = webdriver.FirefoxProfile()
        profile1.set_preference("startup.homepage_welcome_url",
            self.webserver.where_is('simpleTest.html'))
        profile1.update_preferences()

        profile2 = webdriver.FirefoxProfile(profile1.path)
        driver = webdriver.Firefox(firefox_profile=profile2)
        title = driver.title
        driver.quit()
        assert "Hello WebDriver" == title

    def test_that_prefs_are_written_in_the_correct_format(self):
        # The setup gave us a browser but we dont need it
        self.driver.quit()

        profile = webdriver.FirefoxProfile()
        profile.set_preference("sample.preference", "hi there")
        profile.update_preferences()

        assert 'hi there' == profile.default_preferences["sample.preference"]

        encoded = profile.encoded
        decoded = base64.decodestring(encoded)
        fp = BytesIO(decoded)
        zip = zipfile.ZipFile(fp, "r")
        for entry in zip.namelist():
            if entry.endswith("user.js"):
                user_js = zip.read(entry)
                for line in user_js.splitlines():
                    if line.startswith(b'user_pref("sample.preference",'):
                        assert True == line.endswith(b'hi there");')
            # there should be only one user.js
            break
        fp.close()

    def test_that_unicode_prefs_are_written_in_the_correct_format(self):
        # The setup gave us a browser but we dont need it
        self.driver.quit()

        profile = webdriver.FirefoxProfile()
        profile.set_preference('sample.preference.2', unicode('hi there'))
        profile.update_preferences()

        assert 'hi there' == profile.default_preferences["sample.preference.2"]

        encoded = profile.encoded
        decoded = base64.decodestring(encoded)
        fp = BytesIO(decoded)
        zip = zipfile.ZipFile(fp, "r")
        for entry in zip.namelist():
            if entry.endswith('user.js'):
                user_js = zip.read(entry)
                for line in user_js.splitlines():
                    if line.startswith(b'user_pref("sample.preference.2",'):
                        assert True == line.endswith(b'hi there");')
            # there should be only one user.js
            break
        fp.close()

    def test_that_integer_prefs_are_written_in_the_correct_format(self):
        # The setup gave us a browser but we dont need it
        self.driver.quit()

        profile = webdriver.FirefoxProfile()
        profile.set_preference("sample.int.preference", 12345)
        profile.update_preferences()
        assert 12345 == profile.default_preferences["sample.int.preference"]

    def test_that_boolean_prefs_are_written_in_the_correct_format(self):
        # The setup gave us a browser but we dont need it
        self.driver.quit()

        profile = webdriver.FirefoxProfile()
        profile.set_preference("sample.bool.preference", True)
        profile.update_preferences()
        assert True == profile.default_preferences["sample.bool.preference"]

    def test_that_we_delete_the_profile(self):
        path = self.driver.firefox_profile.path
        self.driver.quit()
        assert not os.path.exists(path)

    def test_profiles_do_not_share_preferences(self):
        self.profile1 = webdriver.FirefoxProfile()
        self.profile1.accept_untrusted_certs = False
        self.profile2 = webdriver.FirefoxProfile()
        # Default is true. Should remain so.
        assert self.profile2.default_preferences["webdriver_accept_untrusted_certs"] == True

    def test_none_proxy_is_set(self):
        # The setup gave us a browser but we dont need it
        self.driver.quit()
#.........这里部分代码省略.........
开发者ID:217,项目名称:selenium,代码行数:103,代码来源:ff_profile_tests.py


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