I am looking for the option where I can Verify Element Attribute Value using Boolean. For example title=“Hazard” or href=“www.test.com” I just want to verify if there is any attribute value present and using Boolean. How can I do that? I am using manual mode. Thank you so much!
You have to use one of the attributes of your element. Your can’t just go willy nilly. Done right, the Verify Element Attribute Value returns a boolean if the specific text of the attribute is correct/exists or not.
As an example, in the first one below I am wanting to confirm the <value> attribute and in the second I want to confirm the <title> attribute:
WebUI.verifyElementAttributeValue(findTestObject('myPage/input_DateSDMAcctReceived'), "value", "${gScreenFormattedDate}", 10)
WebUI.verifyElementAttributeValue(findTestObject('myPage/textarea_SDMAcctReviewDetails'), "title", "Choose the appropriate value based on information received", 10)
Leave it blank if the app will allow it. You can “fill” the contents of the parameter at run time.
If you notice my “attributeValue” in my first statement above, I use a variable to validate the contents of the attribute. In my case, this is the current date, but you can use a variable to hold your contents. I don’t know how or where you are going to GET the value:
So you’re just trying to see if there’s a window title in the page as a bool? What grylion said should work…
or maybe the below code is what you looking for… I don’t have a website where I can have the Window title as blank and test it.
Do you think this will work @grylion54
WebUI.openBrowser('https://google.com')
boolean title = WebUI.getWindowTitle()
So that Title is a button attribute…not even a window title. It’s not even the button text. But this code should work… if the “title” is null/false, the test will fail.
Personally, you should NOT use true for your “isRegex” unless you want to make a wild card similar comparison instead of a standard comparison. Since you do not have any wild cards in your text, it can only lead to some problems latter, especially if you are unfamiliar with Regular Expression components, like “$” or “]”
since it’s wrapped with a boolean, it should return true if there’s a value there… false if there isn’t. if you console log (or print) myTitle, it should return true/false depending on if there’s a value set on title attr. (not the actual string)
I mean it’s a weird test req, but this is what the OP wants to do.
@smistry don’t give up. try the codeblock I posted.
the way to test it is to hack the HTML in dev console… and remove the string/value inside the title attr and run the test from that specific test step in the same browser instance without refreshing the page (if you want to verify if the code works or not)
Just for your info: the attribute we are looking at is the <title>, so getAttribute gets the “value”/“information”/“String” that is within the associated <title> attribute, which in your image above is “Sign in to online account”, so:
@ashraf.madina takes the fact there is content within the variable and does a cast to a boolean which may be true; and I just do a comparison to the String variable being empty. Either / or.