本文整理汇总了Python中selenium.webdriver.support.color.Color.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python Color.from_string方法的具体用法?Python Color.from_string怎么用?Python Color.from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.color.Color
的用法示例。
在下文中一共展示了Color.from_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_lobby
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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")))
示例2: test_hex_to_rgba
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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
示例3: test_hsl_to_rgba
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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
示例4: test_hsla_to_rgba
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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
示例5: get_view_color_values
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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
示例6: testShouldPickUpStyleOfAnElement
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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
示例7: wait_for_background_color
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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()
示例8: get_default_value
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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
示例9: test_explore_stock_color
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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)
示例10: state_of_cloud
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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
示例11: getDefaultValue
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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
示例12: test_home
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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
示例13: test_named_color
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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"
示例14: test_named_color
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
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)"
示例15: test_hex3_to_rgba
# 需要导入模块: from selenium.webdriver.support.color import Color [as 别名]
# 或者: from selenium.webdriver.support.color.Color import from_string [as 别名]
def test_hex3_to_rgba(self):
assert Color.from_string("#0f3").rgba == "rgba(0, 255, 51, 1)"