verifyElementHasAttribute should return boolean but instead forces ERROR

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.


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!

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?

1 Like

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:

1 Like

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

But when the button is disabled it shows up

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)

I changed it a little bit

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).

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ā€¦

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.

No, in place of the first two lines:

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.

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.

1 Like

@devalex88 @ThanhTo

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

Awesome, thank you so much!!!

1 Like

Sorry, I missed this postā€¦

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 right on this forum page and put this in the browser consoleā€¦

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.

1 Like

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

@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.

2 Likes

Or maybe this is enough to get you going:

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

Here is my solution to your question:

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