XCTEST - How to extract text from the screenshot and compare it with a expected string - xctest

Currently I am testing one iOS app for localization.
Is there any way we can take a screenshot of the app screen and we extract a text from that screenshot to compare it with the text coming from the locale string file?

To assert texts use accessibility properties of XCUIElement (value and title)
https://developer.apple.com/documentation/xctest/xcuielementattributes
Watch the example here
https://github.com/rzakhar/xctest-assignment
To access translations in your tests refer to a Comparing localized UI texts tip from here
https://www.vvse.com/blog/blog/2018/01/24/tips-for-using-xcodes-ui-testing-solution-xcuitest/
Make sure to write some extensions to reduce boilerplate code

Related

React Native support Display P3 color gamit ? or only srgb?

When we were designing our app we used the sketch display P3 color profile, once we implemented everything in React Native we found that our colors were not the same as the ones designed they seem less lively. I was wondering if anyone knows if there is a solution to this?
I have run into this too. What I ended up doing was convert the colors in Sketch to the sRGB values making the app match the Sketch file.
In Sketch:
Press ⌘+Shift+K This will pull up the color profile switcher
Change the color profile to sRGB
Click Change Profile
Choose the Convert option (or assign if you want to assign RGB values)
You document should now be updated with the values you can use in your app that will match what you see on screen.
This article helped me https://medium.com/fueled-engineering/practical-colour-management-for-app-makers-2b5174c1b8cb

How to get User Location with auto complete in iOS 9? [duplicate]

For example, when I input several letters, the corresponding words will show up automatically and then I can select them. But how to implement this kind of function? Which kind of UI element should I use ? Should I also input all countries in the world in cord data so that I can get the corresponding results ?
The image you've shown appears to be simply a UITableView that appears and is populated in response to what the user types in a UITextField.
If you're working with a table view similar to your screen shot, you can use a UISearchController. Here's a tutorial about it.

How to get system icons in iOS

I want to use icons like opened/closed folder in my table (UITableView)?
UPD:
For example, in Java you can get a standard image "folder" and use it in the FileTree:
new
DefaultTreeCellRenderer().getDefaultClosedIcon()
And also can use the constants of L&F (colors, styles, icons).
In the iOS, I found only these standard icons.
But not folder icons...
I'm not quite sure exactly what you want - the folder icon from iOS? Could you explain a little better?
If it is a folder icon that you want, there's no quick way to get it from code - doing so would use private API's and your app is likely to be rejected from the app store.
If you want something like a folder icon, a good way to get it would be by taking a screenshot of the iPhone simulator and editing it to the right size etc.

Setting parts of a String to Bold in UIView

I'm parsing an XML file an get a string as NSMutableString.
Now I want to show this string as text in my UIView.
So, I created a TextView and set its value to my string. The result was that I have the text with HTML Tags shown up in the TextView.
There is no problem removing the tags from the string, but some of the text needs to appear as bold.
Is there any way to display parts of a string as bold programmatically?
I replaced <br> Elements with \n and it works fine for line-break.
But I still don't know what I can do to display words between strong tags as bold in the UIView.
There are two ways. The first is by displaying them in UIWebViews; prior to iOS 4.1 this was effectively the only way. Because you already have HTML codes in the text, it would certainly be easy.
If you're ok with your app running only on iOS 4.1 and up you can use Core Text, which provides very rich formatting.
EDIT
Apple provides some good resources:
About Text, Web, and Editing Support in iOS
Core Text Programming Guide
WWDC 2010 Session Videos -- follow the link to iTunes and grab session 110: Advanced Text Handling for iPhone OS
(Apple Developer login required)
You may use UIWebView and load your content from an NSString object.
Anyway if you want to stick to Cocoa, have a look to NSAttributedString.

Search and Highlight text in PDF for IPad

I am working on the PDF App for iPad and facing an issue: how to search a text in PDF and also how to highlight that text?
Yours is the same big problem I'm having. My understanding is that, currently on iOS 4.0, the main public API is CGPDF . It allows us to parse PDF, and with it we can search strings in it. See also this Quartz 2D document. It also allows us to render it on the screen using CGContextDrawPage. However, it's not yet possible to get the position of a text in the rendered image. (On OS X it's possible using PDFKit.)
So, I'm afraid that you need to implement the PDF spec yourself to get that info. I think GoodReader etc. is working very very hard to implement these.
I had the same trouble recently and then I found FastPDFKit. Have tested the package and it's working great.
http://mobfarm.eu/fastpdfkit