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


Python color.Color类代码示例

本文整理汇总了Python中selenium.webdriver.support.color.Color的典型用法代码示例。如果您正苦于以下问题:Python Color类的具体用法?Python Color怎么用?Python Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: create_lobby

	def create_lobby(self, name="frederick", color=None):
		driver = InterfaceTest.driver
		self.modal_appear_wait("name")

		name_entry = driver.find_element_by_id("user-nickname")
		name_entry.send_keys(name)
		color_master = driver.find_element_by_id("color-picker")
		color_blocks = color_master.find_elements_by_class_name("ColorBlotch")

		if color is None:
			color_block = random.choice(color_blocks)
			color_block.click()
		else:
			desired_color = Color.from_string(color)
			found = False

			for color_block in color_blocks:
				if Color.from_string(color_block.value_of_css_property("background-color")) == desired_color:
					color_block.click()
					found = True
					break
			if not found:
				raise Exception("unable to find desired color: " + color)
		self.modal_complete()

		username_button = driver.find_element_by_id("change-username")
		self.assertIn(name, username_button.text)

		create_button = driver.find_element_by_id("create-lobby")
		create_button.click()
		self.modal_appear_wait("Lobby")
		self.modal_complete()

		return InterfaceTest.wait.until(ec.visibility_of_element_located((by.ID, "canvas")))
开发者ID:kaihuang201,项目名称:virtualboard,代码行数:34,代码来源:test_interface.py

示例2: test_hex_to_rgba

    def test_hex_to_rgba(self):
        hex_ = "#01Ff03"
        rgba = "rgba(1, 255, 3, 1)"
        assert Color.from_string(hex_).rgba == rgba

        hex_ = "#00ff33"
        rgba = "rgba(0, 255, 51, 1)"
        assert Color.from_string(hex_).rgba == rgba
开发者ID:denis-vilyuzhanin,项目名称:selenium,代码行数:8,代码来源:color_tests.py

示例3: test_hsl_to_rgba

    def test_hsl_to_rgba(self):
        hsl = "hsl(120, 100%, 25%)"
        rgba = "rgba(0, 128, 0, 1)"
        assert Color.from_string(hsl).rgba == rgba

        hsl = "hsl(100, 0%, 50%)"
        rgba = "rgba(128, 128, 128, 1)"
        assert Color.from_string(hsl).rgba == rgba
开发者ID:denis-vilyuzhanin,项目名称:selenium,代码行数:8,代码来源:color_tests.py

示例4: test_named_color

def test_named_color():
    assert Color.from_string("green").rgba == "rgba(0, 128, 0, 1)"
    assert Color.from_string("gray").rgba == "rgba(128, 128, 128, 1)"
    assert Color.from_string("aqua").hex == "#00ffff"
    assert Color.from_string("transparent").rgba == "rgba(0, 0, 0, 0)"
开发者ID:Allariya,项目名称:selenium,代码行数:5,代码来源:color_tests.py

示例5: test_hsla_to_rgba

    def test_hsla_to_rgba(self):
        hsla = "hsla(120, 100%, 25%, 1)"
        rgba = "rgba(0, 128, 0, 1)"
        assert Color.from_string(hsla).rgba == rgba

        hsla = "hsla(100, 0%, 50%, 0.5)"
        rgba = "rgba(128, 128, 128, 0.5)"
        assert Color.from_string(hsla).rgba == rgba
开发者ID:denis-vilyuzhanin,项目名称:selenium,代码行数:8,代码来源:color_tests.py

示例6: get_view_color_values

    def get_view_color_values(self):
        grid = Color.from_string(self.web_driver.find_element_by_name("view_grid").value_of_css_property('color')).hex
        tile = Color.from_string(self.web_driver.find_element_by_name("view_tile").value_of_css_property('color')).hex
        list = Color.from_string(self.web_driver.find_element_by_name("view_list").value_of_css_property('color')).hex

        self.web_session.logger.debug("grid: {}  tile: {}  list: {}".format(grid, tile, list))

        return grid, tile, list
开发者ID:Hawkular-QE,项目名称:cf-ui,代码行数:8,代码来源:settings.py

示例7: testShouldPickUpStyleOfAnElement

def testShouldPickUpStyleOfAnElement(driver, pages):
    pages.load("javascriptPage.html")

    element = driver.find_element(by=By.ID, value="green-parent")
    backgroundColour = Color.from_string(element.value_of_css_property("background-color"))
    assert Color.from_string("rgba(0, 128, 0, 1)") == backgroundColour

    element = driver.find_element(by=By.ID, value="red-item")
    backgroundColour = Color.from_string(element.value_of_css_property("background-color"))
    assert Color.from_string("rgba(255, 0, 0, 1)") == backgroundColour
开发者ID:SeleniumHQ,项目名称:selenium,代码行数:10,代码来源:rendered_webelement_tests.py

示例8: wait_for_background_color

 def wait_for_background_color(self, selector, color_string):
     color = Color.from_string(color_string)
     correct_color = (
         lambda driver: Color.from_string(
             driver.find_element_by_css_selector(selector).value_of_css_property("background-color")
         )
         == color
     )
     msg = "The color of '%s' should be %s" % (selector, color_string)
     Wait(self.sel).until(correct_color, msg)
     self.screenshot()
开发者ID:safarijv,项目名称:sbo-selenium,代码行数:11,代码来源:testcase.py

示例9: get_default_value

def get_default_value(htmlfile, xpath, name, css=True):
  cwd = os.path.dirname(os.path.realpath(__file__))
  driver = None
  while True:
    try:
      driver = selenium.webdriver.Firefox()
      #driver = selenium.webdriver.PhantomJS()
      break
    except:
      time.sleep(1)
  driver.get('file://' + cwd + '/' + htmlfile)
  #driver.set_window_size(800, 600)
  #driver.maximize_window();
  element = driver.find_element_by_xpath(patch_xpath(xpath))
  if css:
    value = element.value_of_css_property(name)
  else:
    value = element.get_attribute(name)
  if not value:
    value = ''
  if '-moz-' in value:
    value = value.replace('-moz-', '')
  if 'color' in name:
    try:
      value = Color.from_string(value).hex
    except:
      pass
  driver.quit()
  time.sleep(1)
  return value
开发者ID:jineli,项目名称:websee,代码行数:30,代码来源:util.py

示例10: test_explore_stock_color

    def test_explore_stock_color(self):

        _explore_css = 'div.span4:nth-child(1) > ul:nth-child(1) > li:nth-child(1) > a:nth-child(1)'
        _expected_result ='#0066cc'

        actual_color = self.driver.find_element_by_css_selector(_explore_css).value_of_css_property('color')

        actual_result = Color.from_string(actual_color).hex
        assert actual_result == _expected_result, "CURRENT: {0}, EXPECTED: {1}".format(actual_result, _expected_result)
开发者ID:laureana7,项目名称:oyl,代码行数:9,代码来源:test_footer_links.py

示例11: state_of_cloud

def state_of_cloud(context,search_cloud,state):
    from .clouds import find_cloud
    cloud = find_cloud(context,search_cloud.lower())
    if not cloud:
        assert False, "Cloud %s is not added" % cloud
    if state not in ['enabled','disabled']:
        raise Exception('Unknown type of state')
    button_state = cloud.find_element_by_class_name('icon').value_of_css_property('background-color')

    color = Color.from_string(button_state).hex
    actual_state = get_color_from_state(state)
    if color != actual_state:
        assert False, "Cloud should be %s, but it is not" % state
开发者ID:mistio,项目名称:mist.tests,代码行数:13,代码来源:buttons.py

示例12: getDefaultValue

def getDefaultValue(filepath, xpath, name, css=True):
  driver = webdriver.Firefox()
#  driver = webdriver.PhantomJS()
  driver.maximize_window()
  driver.get('file://' + filepath)
  element = driver.find_element_by_xpath(xpath)
  if css:
    value = element.value_of_css_property(name)
  else:
    value = element.get_attribute(name)
  if not value:
    value = ''
  if '-moz-' in value:
    value = value.replace('-moz-', '')
  if 'color' in name:
    value = Color.from_string(value).hex
  driver.quit()
  return value
开发者ID:jineli,项目名称:websee,代码行数:18,代码来源:default.py

示例13: test_home

    def test_home(self):

        help_css = 'div.span4.offset1.footer-links-logos > div.hidden-phone > div.row-fluid.footer-links > div.span4 > ul > li:nth-child(3) > a'
        most_popular_q__css = '#rn_PageContent > div > h2'
        expected_result = "MOST POPULAR QUESTIONS"
        expected_url = "https://google.custhelp.com/app/home"

        self.driver.find_element_by_css_selector(help_css).click()
        actual_result = self.driver.find_element_by_css_selector(most_popular_q__css).text
        assert actual_result == expected_result, actual_result
        current_url = self.driver.current_url
        self._wait_for_element(most_popular_q__css)
        assert current_url == expected_url, current_url

        popular_questions_css = '#rn_ProductCategoryList_main_3 > h2:nth-child(1) > div > a'
        actual_color = self.driver.find_element_by_css_selector(popular_questions_css).value_of_css_property('color')
        expected_color = '#c87100'
        actual_color_result = Color.from_string(actual_color).hex
        assert actual_color_result == expected_color, actual_color_result
开发者ID:laureana7,项目名称:oyl,代码行数:19,代码来源:test_footer_links.py

示例14: test_named_color

 def test_named_color(self):
     assert Color.from_string("green").rgba == "rgba(0, 128, 0, 1)"
     assert Color.from_string("gray").rgba == "rgba(128, 128, 128, 1)"
     assert Color.from_string("aqua").hex == "#00ffff"
开发者ID:denis-vilyuzhanin,项目名称:selenium,代码行数:4,代码来源:color_tests.py

示例15: test_hex3_to_rgba

 def test_hex3_to_rgba(self):
     assert Color.from_string("#0f3").rgba == "rgba(0, 255, 51, 1)"
开发者ID:denis-vilyuzhanin,项目名称:selenium,代码行数:2,代码来源:color_tests.py


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