なにもわからない

気分で技術系の雑記を書きます

Selenium IDE は for each したりできるよ

ウェブブラウザのオートメーションツール Selenium には、Google Chrome / Mozilla Firefoxプラグインとして動く、最近開発が活発な Selenium IDE というものがあります。

その Selenium IDE には conditional logic and looping を実現する Control Flow と呼ばれる機能があります。

Selenium IDE comes with commands that enable you to add conditional logic and looping to your tests. This enables you to execute commands (or a set of commands) only when certain conditions in your application are met, or execute command(s) repeatedly based on pre-defined criteria.

docs.seleniumhq.org

何かと言うと if とか for each とか書けるよって話なんですが、まぁ当然 JavaScript の実行結果をイテレートできます。

JavaScript Expressions Conditions in your application are checked by using JavaScript expressions. You can use the execute script or execute async script commands to run a snippet of JavaScript at any point during your test and store the result in a variable. These variables can be used in a control flow command. You can also use JavaScript expressions directly in the control flow commands.

コツは execute script の、 Target には return 式を、Value には格納先変数を書き、変数を ${} で展開すること、くらいでしょうか。

f:id:tamakiii:20191121002629p:plain
Selenium IDE なるほどですね

もっとリッチなエディタがあれば RPA できそうですが(=Microsoft Power Automate に期待してます)、これだけでも人間が学習すればある程度使えそうです。実行環境を用意するのだけ面倒くさそう。