# verifyElementHasAttribute should return boolean but instead forces ERROR

**URL:** <https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726>\
**Category:** Bug Report\
**Tags:** katalon-studio, bugs-report\
**Created:** [November 22, 2019, 3:31pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726 "2019-11-22T15:31:31Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![krista.strzeszkowski](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@krista.strzeszkowski](https://forum.katalon.com/u/krista.strzeszkowski)\
**Post date:** [November 22, 2019, 3:31pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/1 "2019-11-22T15:31:31Z")

</div>

There is a remove button on my webpage that is disabled if there is NO icon image uploaded and will have an attribute of `diabled = 'disabled'`  
I want the code to check and see if this element exists and if it does not then it can click the remove button.

```auto

WebUI.navigateToUrl('website')

WebUI.click(findTestObject('ModifyIcon'))

removeButton = findTestObject('cmdRemoveLogo')

rmbuttonIsDisabled = WebUI.verifyElementHasAttribute(removeButton, 'disabled', 20, FailureHandling.CONTINUE_ON_FAILURE)

WebUI.comment(rmbuttonIsDisabled)

//WebUI.click(removeButton) 

 2019-11-22 10:17:03.413 ERROR c.k.k.core.keyword.internal.KeywordMain - ❌ Object 'cmdRemoveLogo' does not have attribute 'disabled' (Root cause: com.kms.katalon.core.exception.StepFailedException: Object 'cmdRemoveLogo' does not have attribute 'disabled'
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword$_verifyElementHasAttribute_closure1.doCall(VerifyElementHasAttributeKeyword.groovy:89)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword$_verifyElementHasAttribute_closure1.call(VerifyElementHasAttributeKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword.verifyElementHasAttribute(VerifyElementHasAttributeKeyword.groovy:100)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword.execute(VerifyElementHasAttributeKeyword.groovy:69)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementHasAttribute(WebUiBuiltInKeywords.groovy:3166)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementHasAttribute$4.call(Unknown Source)
	at test.run(test:32)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1574435804597.run(TempTestCase1574435804597.groovy:21)
)

```

I thought verifyElementHasAttribute was suppose to return a boolean but I am just getting that it cannot find the attribute. Am I using the keyword incorrectly? Or am I using the wrong keyword?

Thanks!

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [November 22, 2019, 4:25pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/2 "2019-11-22T16:25:07Z")

</div>

> [@krista.strzeszkowski](#):
>
> I thought verifyElementHasAttribute was suppose to return a boolean

It certainly should. I’m wondering if FailureHandling is misbehaving. What happens if you remove it? What happens if you set it to `OPTIONAL`?

One other thing to check - if you think the page updates itself in the background, perhaps you need to wait a little _before_ using `findTestObject()`. SmartWait should help here - is it enabled?

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [November 22, 2019, 4:40pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/3 "2019-11-22T16:40:38Z")

</div>

Relevant code:

```
if (foundElement.getAttribute(attributeName) != null) {
    logger.logPassed(MessageFormat.format(StringConstants.KW_LOG_PASSED_OBJ_X_HAS_ATTRIBUTE_Y, [to.getObjectId(), attributeName] as Object[]))
    return true
} else {
    WebUIKeywordMain.stepFailed(MessageFormat.format(StringConstants.KW_LOG_FAILED_OBJ_X_HAS_ATTRIBUTE_Y, [to.getObjectId(), attributeName] as Object[]), flowControl, null, true)
    return false
}

```

It looks like it does indeed return a boolean value. I agree with russ:

> [@Russ\_Thomas](#):
>
> I’m wondering if FailureHandling is misbehaving. What happens if you remove it? What happens if you set it to `OPTIONAL` ?

---

<div class="post-metadata">

**Author:** ![krista.strzeszkowski](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@krista.strzeszkowski](https://forum.katalon.com/u/krista.strzeszkowski)\
**Post date:** [November 22, 2019, 7:02pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/4 "2019-11-22T19:02:54Z")

</div>

If I remove the failure handle then the test errors out immediately. When the statement is there the test continues but ultimately fails. I am wondering if maybe I am just using it incorrectly. Like because when the button is enabled the attribute is not there

 ![disabled](https://europe1.discourse-cdn.com/katalon/original/2X/1/1fe4077fefee5b4eea2c8d436b013fe9cfa5483a.jpeg)

But when the button is disabled it shows up

 ![enabled](https://europe1.discourse-cdn.com/katalon/original/2X/b/bb032c8e57206ec37f9ec6b5ea284840e565ba8b.jpeg)

So maybe I am using the wrong keyword (or more likely using it incorrectly), I am just trying to make I am asking the right question. When I run the test when the button is in a state of disabled the test runs no issue, when the button is enabled and there is no element the test fails. But I am under the impression that it should just return false and not fail–is that correct?

(Sorry I am still really new to Katalon so I am not the most familiar yet)

---

<div class="post-metadata">

**Author:** ![krista.strzeszkowski](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@krista.strzeszkowski](https://forum.katalon.com/u/krista.strzeszkowski)\
**Post date:** [November 22, 2019, 7:20pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/5 "2019-11-22T19:20:38Z")

</div>

I changed it a little bit

```auto
if (WebUI.verifyElementHasAttribute(removeButton, 'disabled', 20) == true) {
	WebUI.navigateToUrl('https://secure.confirmdelivery.com/MailNet/EZAddress/EZAddress.aspx?MS=Confirmation') 
} else if (WebUI.verifyElementHasAttribute(removeButton, 'disabled', 20) == false) {
	WebUI.click(removeButton)
}

```

`cmdRemoveLogo does not have attribute 'disabled'`

In my understanding it is just supposed to return False but because it does not have attribute. So it is false but it is not returning false instead it is erroring even though it is right. (again sorry I am just so confused).

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [November 22, 2019, 7:21pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/6 "2019-11-22T19:21:24Z")

</div>

> [@krista.strzeszkowski](#):
>
> So maybe I am using the wrong keyword (or more likely using it incorrectly

No, I think you’re using it correctly. Before I go on, I should tell you that the code situated in the `onclick` handler in the first image is at best “poor”. There are better ways to achieve what the developers are trying to achieve than modifying the HTML layout from within the click handler of an input element. What you do with that info is up to you.

I’m still of the opinion that there’s an issue with the FailureHandling. `verifyElementHasAttribute` should return true/false based on the presence of the specified attribute. That said…

Try this…

```javascript
String js = "return document.querySelector('#cmdRemoveLogo').getAttribute('disabled') == true;"
rmButtonIsDisabled = WebUI.executeJavaScript(js, null);

```

If that works, I’ll mark this as a bug report.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [November 22, 2019, 7:44pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/8 "2019-11-22T19:44:22Z")

</div>

> [@krista.strzeszkowski](#):
>
> Add that in addition to the original rmbuttonIsDisabled?

No, in place of the first two lines:

```javascript
String js = "return document.querySelector('#cmdRemoveLogo').getAttribute('disabled') == true;"
boolean rmbuttonIsDisabled = (boolean) WebUI.executeJavaScript(js, null);
WebUI.navigateToUrl('https://secure.confirmdelivery.com/MailNet/EZAddress/EZAddress.aspx?MS=Confirmation')

```

In essence, I’m trying to give you a JS-based equivalent - if it works, I’ll move this to Bug Reports because your use of `verifyElementHasAttribute` should amount to the same thing but it seems it’s broken.

But we’re not there yet - this is one small step…

EDIT: added `(boolean)` cast to be sure.

---

<div class="post-metadata">

**Author:** ![krista.strzeszkowski](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@krista.strzeszkowski](https://forum.katalon.com/u/krista.strzeszkowski)\
**Post date:** [November 22, 2019, 7:47pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/9 "2019-11-22T19:47:53Z")

</div>

Okay so I had to put ‘def’ in front of the rmbutton and then it worked. If I print out the rmbuttonISDisabled to the console it returns false! Adding the Boolean works too.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [November 22, 2019, 7:49pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/10 "2019-11-22T19:49:39Z")

</div>

@devalex88 @ThanhTo

I moved this to Bug Reports. Read the thread for the details. Thanks.

---

<div class="post-metadata">

**Author:** ![krista.strzeszkowski](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@krista.strzeszkowski](https://forum.katalon.com/u/krista.strzeszkowski)\
**Post date:** [November 22, 2019, 7:49pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/11 "2019-11-22T19:49:54Z")

</div>

Awesome, thank you so much!!!

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [November 22, 2019, 7:58pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/12 "2019-11-22T19:58:58Z")

</div>

Sorry, I missed this post…

> [@krista.strzeszkowski](#):
>
> In my understanding it is just supposed to return False but because it does not have attribute.

Well, that’s a choice made by the Katalon developers but yes, that meets with the DOM interface standard. What it should NOT do is force an ERROR.

If you bring up the **[DevTools](http://forum.katalon.com/t/how-to-the-browser-developer-tools-f12-devtools/34329/)** right on this forum page and put this in the browser console…

```auto
document.querySelector('#main').getAttribute('disabled') == "disabled"

```

it will return `false` as expected. `#main` is a `<section>` element on this page. it does NOT have a `disabled` attribute therefore the DOM interface returns `false`.

QED.

---

<div class="post-metadata">

**Author:** ![jpalmer](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jpalmer/32/9922_2.png) [@jpalmer](https://forum.katalon.com/u/jpalmer)\
**Post date:** [November 29, 2019, 6:48am UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/13 "2019-11-29T06:48:25Z")

</div>

I’m new to custom things like this but I think I’m having a similar problem. I’m trying to have my test determine if an element has a CSS attribute (border color) and if it does, to continue to verify that color and if not, to end the test by closing the browser. But every time it runs in a situation where the element doesn’t have that attribute, it fails because of it instead of following the statement telling it to close the browser if it returns false.

The relevant part is the last if/else statements toward the bottom.

```
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable

WebUI.openBrowser(GlobalVariable.baseurl, FailureHandling.CONTINUE_ON_FAILURE)

WebUI.setViewPortSize(1600, 1200, FailureHandling.CONTINUE_ON_FAILURE)

CustomKeywords.'project.ProjectUtils.addItemToCart'()

WebUI.navigateToUrl(GlobalVariable.baseurl + '/checkout/cart')

WebUI.waitForPageLoad(30)

title = WebUI.getWindowTitle()

if (title == 'Your Cart is Empty') {
	CustomKeywords.'project.ProjectUtils.addItemToCart'()

	WebUI.navigateToUrl(GlobalVariable.baseurl + '/checkout/cart')

	WebUI.verifyElementVisible(findTestObject('pageCart/cartContainer'), FailureHandling.CONTINUE_ON_FAILURE)

	WebUI.verifyElementVisible(findTestObject('pageCart/heading'), FailureHandling.CONTINUE_ON_FAILURE)

WebUI.waitForElementClickable(findTestObject('pageCart/discountSectionName'), 60)

WebUI.click(findTestObject('pageCart/discountSectionName'), FailureHandling.STOP_ON_FAILURE)

WebUI.waitForElementVisible(findTestObject('pageCart/discountEnterText'), 30)

WebUI.verifyElementVisible(findTestObject('pageCart/discountEnterText'))

WebUI.setText(findTestObject('pageCart/discountInputField'), 'invalidcode')

WebUI.click(findTestObject('pageCart/discountApplyButton'))

WebUI.waitForElementVisible(findTestObject('pageCart/invalidDiscountMsg'), 30)

WebUI.verifyElementText(findTestObject('pageCart/invalidDiscountMsg'), 'Please enter a valid discount code.')

WebUI.verifyElementHasAttribute(findTestObject('pageCart/discountInputField'), 'border-color', 10, FailureHandling.OPTIONAL)
}

else {

WebUI.verifyElementVisible(findTestObject('pageCart/cartContainer'), FailureHandling.CONTINUE_ON_FAILURE)

WebUI.verifyElementVisible(findTestObject('pageCart/heading'), FailureHandling.CONTINUE_ON_FAILURE)

WebUI.waitForElementClickable(findTestObject('pageCart/discountSectionName'), 60)

WebUI.click(findTestObject('pageCart/discountSectionName'), FailureHandling.STOP_ON_FAILURE)

WebUI.waitForElementVisible(findTestObject('pageCart/discountEnterText'), 30)

WebUI.verifyElementVisible(findTestObject('pageCart/discountEnterText'))

WebUI.setText(findTestObject('pageCart/discountInputField'), 'invalidcode')

WebUI.click(findTestObject('pageCart/discountApplyButton'))

WebUI.waitForElementVisible(findTestObject('pageCart/invalidDiscountMsg'), 30)

WebUI.verifyElementText(findTestObject('pageCart/invalidDiscountMsg'), 'Please enter a valid discount code.')

}

if (WebUI.verifyElementHasAttribute(findTestObject('pageCart/discountInputField'), 'border-color', 20) == false)

{

WebUI.closeBrowser

}

else {

def borderColor = WebUI.getCSSValue(findTestObject('pageCart/discountInputField'), 'border-color')

println(borderColor)

WebUI.verifyEqual('rgb(237, 131, 128)', borderColor)

	WebUI.closeBrowser
}

```

And here is the log after being run in a browser where the discountInputField element does not have the border color attribute.

```
2019-11-29 00:33:13.982 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2019-11-29 00:33:13.988 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/cartBadDiscountCode
2019-11-29 00:33:14.906 DEBUG testcase.cartBadDiscountCode - 1: openBrowser(baseurl, CONTINUE_ON_FAILURE)
2019-11-29 00:33:15.387 INFO c.k.k.core.webui.driver.DriverFactory - Starting 'Firefox (headless)' driver
Nov 29, 2019 12:33:15 AM org.openqa.selenium.remote.DesiredCapabilities firefox
INFO: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
2019-11-29 00:33:15.593 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 seconds
1575009197593	mozrunner::runner	INFO	Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-headless" "-foreground" "-no-remote" "-profile" "C:\\Users\\jpalmer\\AppData\\Local\\Temp\\rust_mozprofile.Lcxwf72cDFwf"
*** You are running in headless mode.
1575009198030	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1575009198030	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry
1575009198030	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1575009198030	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory.
1575009200038	Marionette	INFO	Listening on port 60383
1575009200209	Marionette	WARN	TLS certificate errors will be ignored for this session
1575009200216	Marionette	INFO	Proxy settings initialised: {"proxyType":"direct"}
Nov 29, 2019 12:33:20 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
2019-11-29 00:33:20.343 INFO c.k.k.core.webui.driver.DriverFactory - sessionId = 3d7d1bfa-2546-45fe-ab3b-90d78e7bce53
2019-11-29 00:33:20.372 INFO c.k.k.core.webui.driver.DriverFactory - browser = Firefox 70.0
2019-11-29 00:33:20.373 INFO c.k.k.core.webui.driver.DriverFactory - platform = Windows 10
2019-11-29 00:33:20.374 INFO c.k.k.core.webui.driver.DriverFactory - seleniumVersion = 3.141.59
2019-11-29 00:33:20.375 INFO c.k.k.core.webui.driver.DriverFactory - proxyInformation = ProxyInformation{proxyOption=NO_PROXY, proxyServerType=HTTP, password=, proxyServerAddress=, proxyServerPort=0}
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
2019-11-29 00:33:26.701 DEBUG testcase.cartBadDiscountCode - 2: setViewPortSize(1600, 1200, CONTINUE_ON_FAILURE)
2019-11-29 00:33:26.803 DEBUG testcase.cartBadDiscountCode - 3: project.projectUtils.addItemToCart()
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript error: https://staging.project.com/pub/static/version1574959773/frontend/Scottsbase/project/en_US/requirejs/require.js, line 166: Error: Script error for: MutationObserver
http://requirejs.org/docs/errors.html#scripterror
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
2019-11-29 00:33:42.822 INFO k.k.c.m.CustomKeywordDelegatingMetaClass - project.projectUtils.addItemToCart is PASSED
2019-11-29 00:33:42.822 DEBUG testcase.cartBadDiscountCode - 4: navigateToUrl(baseurl + "/checkout/cart")
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript error: https://staging.project.com/checkout/cart, line 98: ReferenceError: project is not defined
JavaScript error: https://staging.project.com/checkout/cart, line 776: SyntaxError: invalid escape sequence
2019-11-29 00:33:45.521 DEBUG testcase.cartBadDiscountCode - 5: waitForPageLoad(30)
2019-11-29 00:33:45.686 DEBUG testcase.cartBadDiscountCode - 6: title = getWindowTitle()
2019-11-29 00:33:45.709 DEBUG testcase.cartBadDiscountCode - 7: if (title == "Your Cart is Empty")
2019-11-29 00:33:45.711 DEBUG testcase.cartBadDiscountCode - 8: else
2019-11-29 00:33:45.712 DEBUG testcase.cartBadDiscountCode - 1: verifyElementVisible(findTestObject("pageCart/cartContainer"), CONTINUE_ON_FAILURE)
2019-11-29 00:33:45.973 DEBUG testcase.cartBadDiscountCode - 2: verifyElementVisible(findTestObject("pageCart/heading"), CONTINUE_ON_FAILURE)
2019-11-29 00:33:46.254 DEBUG testcase.cartBadDiscountCode - 3: waitForElementClickable(findTestObject("pageCart/discountSectionName"), 60)
2019-11-29 00:33:46.742 DEBUG testcase.cartBadDiscountCode - 4: click(findTestObject("pageCart/discountSectionName"), STOP_ON_FAILURE)
2019-11-29 00:33:47.402 DEBUG testcase.cartBadDiscountCode - 5: waitForElementVisible(findTestObject("pageCart/discountEnterText"), 30)
2019-11-29 00:33:47.701 DEBUG testcase.cartBadDiscountCode - 6: verifyElementVisible(findTestObject("pageCart/discountEnterText"))
2019-11-29 00:33:47.956 DEBUG testcase.cartBadDiscountCode - 7: setText(findTestObject("pageCart/discountInputField"), "invalidcode")
2019-11-29 00:33:48.219 DEBUG testcase.cartBadDiscountCode - 8: click(findTestObject("pageCart/discountApplyButton"))
JavaScript error: https://staging.project.com/pub/static/version1574959773/frontend/Scottsbase/project/en_US/requirejs/require.js, line 166: Error: Script error for: Magento_Checkout/js/model/default-validation-rules
http://requirejs.org/docs/errors.html#scripterror
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript warning: https://assets.adobedtm.com/launch-ENdc5122c796634d54be3363c5024a184f.min.js, line 7: Error: WebGL warning: <SetDimensions>: Failed to create WebGL context: WebGL creation failed: 
* Can't use WebGL in headless mode (https://bugzil.la/1375585).
JavaScript error: https://staging.project.com/checkout/cart, line 767: SyntaxError: invalid escape sequence
2019-11-29 00:33:51.975 DEBUG testcase.cartBadDiscountCode - 9: waitForElementVisible(findTestObject("pageCart/invalidDiscountMsg"), 30)
2019-11-29 00:33:52.115 DEBUG testcase.cartBadDiscountCode - 10: verifyElementText(findTestObject("pageCart/invalidDiscountMsg"), "Please enter a valid discount code.")
2019-11-29 00:33:52.309 DEBUG testcase.cartBadDiscountCode - 9: if (verifyElementHasAttribute(findTestObject("pageCart/discountInputField"), "border-color", 20) == false)
2019-11-29 00:33:52.806 ERROR c.k.k.core.keyword.internal.KeywordMain - ❌ Object 'Object Repository/pageCart/discountInputField' does not have attribute 'border-color' (Root cause: com.kms.katalon.core.exception.StepFailedException: Object 'Object Repository/pageCart/discountInputField' does not have attribute 'border-color'
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword$_verifyElementHasAttribute_closure1.doCall(VerifyElementHasAttributeKeyword.groovy:89)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword$_verifyElementHasAttribute_closure1.call(VerifyElementHasAttributeKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword.verifyElementHasAttribute(VerifyElementHasAttributeKeyword.groovy:100)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword.execute(VerifyElementHasAttributeKeyword.groovy:69)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:60)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementHasAttribute(WebUiBuiltInKeywords.groovy:3182)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementHasAttribute$12.call(Unknown Source)
	at cartBadDiscountCode.run(cartBadDiscountCode:82)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1575009190565.run(TempTestCase1575009190565.groovy:23)
)
2019-11-29 00:33:52.809 DEBUG testcase.cartBadDiscountCode - 1: closeBrowser
2019-11-29 00:33:52.812 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/cartBadDiscountCode FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Object 'Object Repository/pageCart/discountInputField' does not have attribute 'border-color' (Root cause: com.kms.katalon.core.exception.StepFailedException: Object 'Object Repository/pageCart/discountInputField' does not have attribute 'border-color'
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword$_verifyElementHasAttribute_closure1.doCall(VerifyElementHasAttributeKeyword.groovy:89)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword$_verifyElementHasAttribute_closure1.call(VerifyElementHasAttributeKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword.verifyElementHasAttribute(VerifyElementHasAttributeKeyword.groovy:100)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword.execute(VerifyElementHasAttributeKeyword.groovy:69)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:60)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementHasAttribute(WebUiBuiltInKeywords.groovy:3182)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementHasAttribute$12.call(Unknown Source)
	at cartBadDiscountCode.run(cartBadDiscountCode:82)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1575009190565.run(TempTestCase1575009190565.groovy:23)
)
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:39)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword$_verifyElementHasAttribute_closure1.doCall(VerifyElementHasAttributeKeyword.groovy:89)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword$_verifyElementHasAttribute_closure1.call(VerifyElementHasAttributeKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword.verifyElementHasAttribute(VerifyElementHasAttributeKeyword.groovy:100)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyElementHasAttributeKeyword.execute(VerifyElementHasAttributeKeyword.groovy:69)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:60)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyElementHasAttribute(WebUiBuiltInKeywords.groovy:3182)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyElementHasAttribute$12.call(Unknown Source)
	at cartBadDiscountCode.run(cartBadDiscountCode:82)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1575009190565.run(TempTestCase1575009190565.groovy:23)
Caused by: com.kms.katalon.core.exception.StepFailedException: Object 'Object Repository/pageCart/discountInputField' does not have attribute 'border-color'
	... 20 more
```

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [November 29, 2019, 1:17pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/15 "2019-11-29T13:17:10Z")

</div>

@jpalmer your problem is, `border-color` is a _style property_, not an HTML attribute. Worse, perhaps, all elements have a style property and all properties unspecified by the author exist with empty `""/null` values.

In other words, `verifyElement(Not)HasAttribute` is not the solution.

My advice, start a new Topic (because we’re “off-topic” for this one) and I’ll fix it there.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [November 30, 2019, 4:41am UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/16 "2019-11-30T04:41:45Z")

</div>

> [@Russ\_Thomas](#):
>
> My advice, start a new Topic (because we’re “off-topic” for this one) and I’ll fix it there.

Or maybe this is enough to get you going:

> [@\[Tip\] How to verify element.style properties](http://forum.katalon.com/t/tip-how-to-verify-element-style-properties/36977):
>
> Using WebUI, there is no direct way to verify/check the style properties of an HTML element. Some users have tried using verifyElement(Not)HasAttribute() - the problem with that is, the style property is not an HTML attribute. Perhaps even worse, the style property has its own properties! The only reasonable way to test style property values is to use JavaScript. In Groovy, you can execute a block of JavaScript code using the WebUI method, executeJavaScript() WebUI.executeJavaScript('alert("H…

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [November 29, 2020, 12:05am UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/17 "2020-11-29T00:05:44Z")

</div>

Automatically bumped on November 29, 2020, 12:05am UTC



---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [November 27, 2021, 8:35pm UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/18 "2021-11-27T20:35:11Z")

</div>

Automatically bumped on November 27, 2021, 8:35pm UTC



---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [November 28, 2021, 2:13am UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/19 "2021-11-28T02:13:44Z")

</div>

I think, your question on one of the FAQ in this forum, but has never been addressed.

Here is my solution to your question:

> [@How to verify CSS property of HTML element](http://forum.katalon.com/t/how-to-verify-css-property-of-html-element/60395):
>
> Problem to solve Here is an usual web page. [User forum page](http://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/) I want to write a Test Case script in Katalon Studio, that verifies if the background-color of the page header elemennt is #1779de . [[screenshot]](https://github.com/kazurayam/ks_verify_CSS_property_computed/blob/master/docs/images/screenshot.png) Katalon Studio does not provide a built-in Keyword that solves my problem out of box. I need to develop a custom solution. But how? Solution In JavaScript on browser, you can call window.getComputedStyle(element) : [Winndow.getComputedStyle(element)](https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle) The Window.getComputedStyle() me…

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [November 28, 2022, 2:13am UTC](https://forum.katalon.com/t/verifyelementhasattribute-should-return-boolean-but-instead-forces-error/36726/20 "2022-11-28T02:13:46Z")

</div>

Closed on November 28, 2022, 2:13am UTC

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
