Search code examples
swiftxcode-ui-testing

How to UI test if an attributed string is crossed out or not


I am using this method to cross out a string

let attributeString: NSMutableAttributedString =  NSMutableAttributedString(string: "Your Text")
    attributeString.addAttribute(NSStrikethroughStyleAttributeName, value: 2, range: NSMakeRange(0, attributeString.length))

yourLabel.attributedText = attributeString

now, I am creating a UI test to test a label. I want to check if the label is crossed out (Strikethrough) or not.

How can I do that?

This is the UI test code

let mastertableviewTable = app.tables["masterTableview"]
let staticText = mastertableviewTable.staticTexts["task two"]

Solution

  • The only answer to this, is I shouldn't UI test how content looks like, but I should test if the specific content is available of not. as there is no way in UI testing we can get objects attributes, like color, font size ...