Robotframework Seleniumlibrary - 提取类子元素

Robotframework Selenium Library - extract clas sub-element

我需要在初始选择器之后提取属性“子元素”。

我将此语法用作选择器:

${first_video}=    Get WebElement    xpath:(//div[contains(@data-store, 'videoID')])[1]

这正确地给我这个单一元素部分:

<div class="alpha" data-store="{"videoID":"1234","playerFormat":"inline","playerOrigin":"video_home","external_log_id":null,"external_log_type":null,"playerSuborigin":"entry_point",
"useOzLive":false,"playOnClick":true,
"videoScrollUseLowThrottleRate":true,"playInFullScreen":false,"type":"video","src":"https:\/\/video.test.com\/v\/a\/123_n.mp","width":320,"height":180,
"videoURL":"https:\/\/www.test.com\/test\/videos\/12345\/","disableLogging":false}" data-sigil="Video">
</div>

我的目标是获取 VideoURL 属性。

我试过

${first_video_link}=    Call Method       ${first_video}    value_of_css_property    data-store.videoURL

但它给了我空输出。 有没有我遗漏的特定语法?

非常感谢

获取 data-store 属性的值:

${val}=    Get Element Attribute    ${your locator}

它似乎是一个合适的 json,因此将其转换为 python 字典,然后访问它的键:

${as json}=     Evaluate    json.loads("""${val}""")    json
Log To Console    The videoURL is ${as json['videoURL']}