Choice of Language?

Friends

I have been using Javascript/WD for a few weeks to automate a iOS app. I chose Javascript as from the choices available it was the one I was most familiar with.

Having moved, some what, through the learning curve for Appium I am questioning my choice. JS is very primitive in terms of modern languages, there is no compiler pass before it runs so simple syntactic mistakes are not found until runtime. Also the await/async syntax, albeit simple and easy to understand, keeps tripping me out as being untyped, returning a promise is no different to returning a value as far as the JS runtime is concerned, but for programme logic it really matters. Obviously. That is not even caught at runtime by JS, but by Appium.

Looking at the choices listed it looks like C# and Java are the only statically typed and compiled languages that will help with these problems. I have not seen any sign of people using C#, but because in my firm there are C# programmers it could be a good choice. I see a lot of Java but the reverse applies - no Java programmers here.

And then there is Typescript. I have no experience with Typescript, has anybody here used Typescript to control Appium? I believe it is strongly typed and does a parse, so would catch alot of my silly mistakes. Since I have some Javascript knowledge, if it could, it would be a good choice.

Python is not a choice for me. It has all the problems of Javascript and its only advantage is that it is widely used.

I know no Ruby. Maybe I should learn?

Edit: Perhaps there are static JS checkers I could use? (A bit OT for this forum… sorry)

I would try WebDriverIO+TypeScript. The latest version of it has been rewritten completely to properly support typing. Together with ESLint it ensures a very decent static source control.

As for Python it also supports typing and asynchronous programming approach since version 3.7. Appium Python client offers types support since version 1. You’d have to use mypy and properly annotate variable/method definitions to achieve a good level of linter coverage.

1 Like

I will look into that. Typescript sounds attractive.

OT but WebdriverIO. I am using…

const wd = require('wd');
const driver = wd.promiseChainRemote("http://localhost:4723/wd/hub");

Is that what you mean? Am I using something different?

Typescript sounds good in theory. But I am having serious problems in practice

I am getting hundreds of errors of the type:

 % tsc --outDir built --allowjs src/sleep 
../../../../node_modules/webdriverio/build/commands/browser/$$.d.ts:49:46 - error TS2694: Namespace 'global.WebdriverIO' has no exported member 'Browser'.

49 export default function $$(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<ElementArray>;
../../../../node_modules/webdriverio/build/commands/browser/$$.d.ts:49:68 - error TS2694: Namespace 'global.WebdriverIO' has no exported member 'Element'.
49 export default function $$(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<ElementArray>;
                                                                      ~~~~~~~

(Lightly edited for clarity)

This is to run tsc over the simple file:

"use strict"
const { default: waitUntil } = require('webdriverio/build/commands/browser/waitUntil');

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
exports.sleep = sleep;

That is a road block right at the start. Being brand new to the world of Typescript I do not have the foggiest clue where to start diagnosing this.