0
votes

enter image description here

I do not know how to locate the pseudo element ,while using robotframework-selenium2Library to do web test. Any help is useful.Thanks.

the test script is like below: Click Element my_element
ID: Click Element | id=my_element Matches by @id attribute

Thank to Alex Bruce, it works.

1
why don't you use the css to locate the element find_element_by_css_selector("span.layui-layer-setwin>a")Alex Bruce
How do you want to handle pseudo element? What is desired output?Andersson
it is auto test script like below: click element "span.layui-layer-setwin>a"Diese Xu
@Alex Bruce , I am tyringDiese Xu
@DieseXu, if you want to click, then you need <a> element. ::before is not a part of DOM, so you cannot locate and click itAndersson

1 Answers

-1
votes

Pseudo web elements wont be part of DOM so it is not possible to get attribute value from selenium2library. Instead we can get it from Execute Javascript like below snippet.

${attribute_value}=    Execute Javascript    return window.getComputedStyle(${element},${pseudo_element}).getPropertyValue('${attribute}');

I was looking for same and found great working code in below link. (JFI - No promo)

Check key "Get Pseudo Element CSS Attribute Value" in the below link.

https://adiralashivaprasad.blogspot.com/2018/06/how-to-get-pseudo-element-css-attribute.html