栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在机器人框架中获取文本溢出的CSS样式

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在机器人框架中获取文本溢出的CSS样式

更新:在当前的SeleniumLibrary(3.2+)中,有一个专用关键字:Get Element
Attribute(获取元素属性)


SeleniumLibrary for Robot
framework不支持获取CSS属性的值。但是,

value_of_css_property
Selenium
Python模块中有一种方法可以完全做到这一点。

为了在元素上调用方法,

CallMethod
可以在任何Robot变量或对象上使用standard关键字。在下面的示例中,我使用Google主页创建了一个自定义关键字和一些示例。应该根据您的目的轻松修改它们。

*** Settings ***Library    SeleniumLibrarySuite Teardown    Close All Browsers*** Test Cases ***TC    Open Browser    http://www.google.com    Chrome    # a CSS property from the element.    ${element_prop}=    Get CSS Property Value    id=SIvCob    line-height    Should Be Equal As Strings    ${element_prop}    28px    # a CSS property inherited from the <body> tag.    ${body_prop}=    Get CSS Property Value    id=SIvCob    font-family    Should Be Equal As Strings    ${body_prop}    arial, sans-serif*** Keywords ***Get CSS Property Value    [documentation]    ...    Get the CSS property value of an Element.    ...        ...    This keyword retrieves the CSS property value of an element. The element    ...    is retrieved using the locator.    ...        ...    Arguments:    ...    - locator(string)    any Selenium Library supported locator xpath/css/id etc.    ...    - property_name     (string)    the name of the css property for which the value is returned.    ...        ...    Returns  (string)    returns the string value of the given css attribute or fails.    ... [Arguments]    ${locator}    ${attribute name}    ${css}=         Get WebElement    ${locator}    ${prop_val}=    Call Method       ${css}    value_of_css_property    ${attribute name}    [Return]     ${prop_val}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/447902.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号