Aero10
(Josh)
4 February 2023 17:43
1
Hello all,
I am wondering whether there is an alternative to Element Should Be Visible keyword from SeleniumLibrary in the Browser library?
It is a useful keyword to me, as well as some other "Should be"s. Did you replace it in some other way in your own tests?
Thank you and best regards,
J
_daryl
(daryl)
4 February 2023 17:57
2
2 Likes
René
(René)
4 February 2023 18:14
3
As _daryl mentioned:
Get Element States is the keyword you are looking for.
It can not only check for visibility but also its absence (hidden) or if an element is enabled or readonly etc.
Because it âreturnsâ multiple states at the same time, you check if a desired state is contained in the list of returned states.
Get Element States id=yourelement contains visible
Or even more information at the same time:
Get Element States id=yourelement contains visible enabled editable
Or the opposite if an element is âhiddenâ
Get Element States id=yourelement contains hidden
You can also watch the talk from last RoboCon
3 Likes
Aero10
(Josh)
4 February 2023 20:39
4
Thank you very much to both of you. This does the trick indeed!
1 Like
Monika
(Monika)
2 October 2023 07:14
5
Hi ,
Can I use Get Element States when I want to check that an element is visible and contains the text âxyzâ ? If yes how I should use it? Could you give me an example?
Thank you in advance for your answer,
Monika
terry.jp
(Terry McCabe)
5 October 2023 12:57
6
You could use:
Get Element States css=yourelement:has-text("xyz") contains visible
Get Element States xpath=yourelement[contains(text(), "xyz")] contains visible
or alternatively:
Get Element States id=yourelement contains visible
Get Text id=yourelement. *= xyz
@Monika If want to do something with an element that is visible and has a certain text, you can also chain engines and do something like this:
Highlight Elements a >> visible=true >> text=new
This will highlight all a elements that a visible and contain the text ânewâ
1 Like