1

I have a mobile app that has many static URLs to various web pages (it is a content-rich mobile app) that get loaded in the in-app browser during the use of the app.

The problem is that these URLs sometimes no longer work (e.g., 404 error). It would be a pain to manually test every single URL regularly when an automated process should be more efficient and painless. Besides, since these are all static URLs and I have the source code, I imagine there should be a tool that can scrape all of the URLs and automate the loading (for testing) one by one, then compile the results for me.

Can anybody suggest a good solution? If the solution could at the same time do spell checking of all strings in the app, that would be good too. The client had noticed some broken URLs and some typos and has requested that we check thoroughly.

I found on this site that there are a few questions on checking URLs in an automated fashion, but these are for websites rather than mobile apps, e.g., example 1 and example 2

For mobile app testing, there are questions like this, but not specifically about URLs.

My apps are native mobile apps for iOS and android, written in objective C and java, respectively.

1
  • 1
    Which part of this are you stuck on? Anything that can make a request can check what the status code (or other outcome) for a given URL is, and therefore given a list/array of URLs print out those that don't succeed (e.g. anything but a 2xx status). On the command line there's ping as suggested below or e.g. curl, or if you want neater reporting use whatever test library you're familiar with and write a parameterised test that asserts on success for a given URL. You could trawl through the source for URL-looking-things, but it would be better if they were extracted to a common location anyway.
    – jonrsharpe
    Dec 30, 2020 at 11:10

2 Answers 2

1

There are several ways to get the URLs from your application.

You could write a couple of automated tests that navigate through your application and get the URLs using locator strategies from the UI.

  • Appium - for both Android and iOS apps
  • XCode - for iOS apps
  • Espresso - for Android apps
  • others maybe

However using this approach would make your tests really slow and you would need to maintain and update them maybe every time the UI for application is changed.

since these are all static URLs and I have the source code

Having this in mind, the best approach would be to shift left your testing effort.

Start by thinking how those URLs get populated in your application.

  • Is there an API resource that is being called and returns all these URLs?
  • Are they being read from a datasource (file, database, cloud storage, etc)?

Once you have your answer, the best way would be to mimic that behaviour.

Afterwards it's a matter of choosing how do you want to verify that they're not broken:

  • ping or curl (as already mentioned in the previous answer)
  • HTTP requests using the programming language you're most comfortable with
  • any tool from the link you've mentioned so far that is able to load data from an external file
-1

The details will depend on what technology your app is built upon, but the core point is to create a test that will run the command:

ping -c 1 *URL*

for each URL you want to check. This will make ping stop after one request only.

If we are talking about a JVM-based stack, this article may help to understand how to run Bash commands with Java, but if you are confident in it, you may want to copy this code to run commands.

Here is the documentation of the Process class.

1
  • Thanks, I have added a bit more info on the technology the app is built upon. It is two separately coded apps - one for android, one for iOS. Dec 30, 2020 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.