This is a migrated thread and some comments may be shown as answers.

How to verify an HTML element's class

4 Answers 92 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 16 Dec 2014, 10:15 PM
I viewed this page 

http://docs.telerik.com/teststudio/testing-framework/write-tests-in-code/intermediate-topics-wtc/element-identification-wtc/finding-page-elements

and still am not sure on how to achieve my goal. I am trying to verify that an HTML element's class is "RequiredInvalid". All I have as a basis is the code to check that the element's value is not "".

[code]
Public Sub TX_1V_1D_Prod_ScriptTest_CodedStep()
        'Verify input 'FnameText' value 'Exact' ''.
        Assert.IsTrue(ArtOfTest.Common.CompareUtils.StringCompare(Pages.{page name here}.FrameObjTabFrame.FnameText.Value, "", ArtOfTest.Common.StringCompareType.Exact))
End Sub
[/code]

The element's name is FnameText. How would I tweak the above code to verify that FnameText's class is "RequiredInvalid"?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 19 Dec 2014, 01:08 PM
Hi Randy,

The Telerik Testing Framework has its own AssertAttribute method. You can verify the class as follows:

YouElement.AssertAttribute().Value("class", ArtOfTest.Common.StringCompareType.Same, "RequiredInvalid");

Hope this helps.


Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Randy
Top achievements
Rank 1
answered on 19 Dec 2014, 03:45 PM
Ah, thanks! I think this will fix my issue. 

I had another question, but I can put it in another post if I need to.  I am trying to test some javascript validation on a page.  Is there a way to verify that 
a) a popup [javascript alert] has occurred; and 
b) verify the text of the popup?

I've been looking in the documentation and haven't seen anything about this. Thanks once again!
0
Randy
Top achievements
Rank 1
answered on 19 Dec 2014, 03:54 PM
I don't see a way to edit posts. The Modal popup wasn't Javascript, it was a VBScript window in IE, if it matters.
0
Boyan Boev
Telerik team
answered on 24 Dec 2014, 06:42 AM
Hello Randy,

Please check out this article which handles such cases.

Hope this helps.

Regards,
Boyan Boev
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Randy
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Randy
Top achievements
Rank 1
Share this question
or