verifyElementAttributeValue returns false if the order of multiple attribute values are changed

When the order of multiple attribute values in the args of above method are changed and it executes, returns false.
The first one below is example of correct order and the second one is wrong order.

WebUI.verifyElementAttributeValue(findTestObject('Object Repository/'), 'class', 'form-control align-self-center', Common.TIMEOUT.getValue())


WebUI.verifyElementAttributeValue(findTestObject('Object Repository/'), 'class', 'align-self-center form-control', Common.TIMEOUT.getValue())

So I use the way like below to be flexible, but it’s a little bit tedious.
Is there a way to write smarter?

String val = WebUI.getAttribute(findTestObject('Object Repository/webTest/region/index/input_search'), 'class')
if(!val.contains('form-control')) {
	KeywordUtil.markFailedAndStop("form not contains!!!")

I think your code of 3 lines is good enough.

If you are going to repeat it many times and want to make your test case script short, you should write a custom Keyword that wraps your 3 lines. Namely,

  • my.Util.verifyElementAttributeContains(TestObject tObj, String attrName, String contained)

Then you can replace your 3 lines to 1.

1 Like

Thank you.
I’ll use custom Keyword to wrap 3 lines.

You can read the source of WebUI.verifyElementAttributeValue keyword here.

Your new custom keyword would be 99% same as this. The only difference would be Line#87

    if (foundElement.getAttribute(attributeName).equals(attributeValue)) {

You want this:

    if (foundElement.getAttribute(attributeName).contains(attributeValue)) {
1 Like

I see, that method requires exactly same String.
From now, I’ll look at opened source code as much as possible.
Thank you so much.

Imagine that the WebUI.verifyElementAttributeValue keyword is coded like this:

    if (foundElement.getAttribute(attributeName).contains(attributeValue)) {

Then it will work as follows.

WebUI.verifyElementAttributeValue(findTestObject('Object Repository/'),
    'class', 'form-control align-self-center', Common.TIMEOUT.getValue())

this will return true as you know,


WebUI.verifyElementAttributeValue(findTestObject('Object Repository/'),
    'class', 'form-control', Common.TIMEOUT.getValue())

this will return true also. I think this behavior is better than the current implementation.

Just a little regrettable ちょっと惜しかったね。

1 Like


A little regrettable.

@kazurayam @ThanhTo

What’s needed is this…


It’s justifiable because class, (also like style) can have multiple values. Sticking with any notional isEqual will usually fall short of rigororous testing needs.

Returning to the OP…

@shunmatsu_begginer If I understood your need correctly, you want to retrieve the value and check it’s equal to something. You don’t need “contains” if the order of the classnames is important.


I like this signature.

I overlooked it. Thank you.