SeleniumHQ / selenium-ide

Open Source record and playback test automation for the web.
https://selenium.dev/selenium-ide/
Apache License 2.0
2.84k stars 768 forks source link

How can we use 'Virtual Authenticator' for the applications that authenticate users in a passwordless manner. #1818

Open techienomad opened 7 months ago

techienomad commented 7 months ago

Virtual Authenticator is a representation of the Web Authenticator model to authenticate users in a passwordless manner.

This was implemented in all Selenium language bindings as per this issue.

How can we use this in the selenium-side-runner to authenticate the applications in the side script?

As per the Virtual Authenticator we need to pass some options, how can we pass these options in selenium-side-runner?

Thanks.

toddtarsi commented 7 months ago

Good question! Maybe we should look at adding a new command for this? Of course, the big challenge here is that this does not map cleanly to two arguments. We need to at some point look at supporting more than two inputs anyway. Target / value for everything is really a poor abstraction. This will take a couple weeks, but I think it should be pursued in this order:

  1. Allow some commands to be defined in a "new" format that isn't attached to just target / value, and has better support for argument typing.
  2. Define this command in the new way.
techienomad commented 7 months ago

Maybe we can use existing "targets" to have multiple values.

Shall I convert this into a Feature Proposal type so that this can be tracked as a new feature?

toddtarsi commented 7 months ago

@techienomad - If you need something immediately for a project, you can just solve this with a plugin that meets your spec easily. You'd define it like this file. The driver object is an instance of selenium-webdriver, so it really should match up with the example you linked pretty seamlessly I think.

https://github.com/SeleniumHQ/selenium-ide/blob/14d01a40962dd89cf154c7e696fb8c9aef70fa4d/packages/side-example-suite/src/plugins/custom-click/index.ts

Plugins in v4 are just kind of written to be way easier to write. It's really just basically nodejs require with some extra checks for the object on default. If you write something and it seems really clean, you can even publish as it's own package like side-v4-plugin-add-virtual-authenticator-command or something like that and then people can just npm install it and add it to the project by name. Here's a bit more about that:

https://github.com/SeleniumHQ/selenium-ide/wiki/V4-Plugin-Guide

techienomad commented 7 months ago

Hi @toddtarsi

This is not immediately required for my project. If you could provide this functionality as part of the side-runner then it would be great.

I will also go through the V4 plugin guide and get my hands dirty in building the new Authenticator plugin.

Thanks.

techienomad commented 6 months ago

Hi @toddtarsi I was referring to the plugin guide and the example code. But I got the below error when I was trying to execute. Please apologize I have very little knowledge of Javascript/Typescript.

Thanks.

console.debug Loading plugin from path... <>/nodejs/side/side-example-suite/dist/plugins/custom-click/index.ts at node_modules/@seleniumhq/side-runtime/src/plugins.ts:31:15 at Array.map () console.debug Loading plugin from path... <>/nodejs/side/side-example-suite/dist/plugins/custom-click/index.ts at node_modules/@seleniumhq/side-runtime/src/plugins.ts:31:15 at Array.map () FAIL ../../../../../usr/local/lib/node_modules/selenium-side-runner/dist/main.test.js ● Running project Plugin › Running suite checks › Running test Plugin Commands Jest encountered an unexpected token Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax. Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration. By default "node_modules" folder is ignored by transformers. Here's what you can do: • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it. • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config. • If you need a custom transformation specify a "transform" option in your config. • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option. You'll find more details and examples of these config options in the docs: https://jestjs.io/docs/configuration For information about custom transformations, see: https://jestjs.io/docs/code-transformation Details: SyntaxError: <>/nodejs/side/side-example-suite/dist/plugins/custom-click/index.ts: Missing initializer in const declaration. (9:12) 7 | */ 8 |

9 | const plugin: PluginShape = { | ^ 10 | commands: { 11 | customClick: { 12 | name: 'custom click', at constructor (node_modules/@babel/parser/src/parse-error.ts:74:19) at Parser.toParseError [as raise] (node_modules/@babel/parser/src/tokenizer/index.ts:1490:19) at Parser.raise [as parseVar] (node_modules/@babel/parser/src/parser/statement.ts:1550:16) at Parser.parseVar [as parseVarStatement] (node_modules/@babel/parser/src/parser/statement.ts:1196:10) at Parser.parseVarStatement [as parseStatementContent] (node_modules/@babel/parser/src/parser/statement.ts:550:21) at Parser.parseStatementContent [as parseStatementLike] (node_modules/@babel/parser/src/parser/statement.ts:421:17) at Parser.parseStatementLike [as parseModuleItem] (node_modules/@babel/parser/src/parser/statement.ts:358:17) at Parser.parseModuleItem [as parseBlockOrModuleBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1388:16) at Parser.parseBlockOrModuleBlockBody [as parseBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1362:10) at Parser.parseBlockBody [as parseProgram] (node_modules/@babel/parser/src/parser/statement.ts:217:10) at Parser.parseProgram [as parseTopLevel] (node_modules/@babel/parser/src/parser/statement.ts:199:25) at Parser.parseTopLevel [as parse] (node_modules/@babel/parser/src/parser/index.ts:45:10) at parse (node_modules/@babel/parser/src/index.ts:66:38) at parser (node_modules/@babel/core/src/parser/index.ts:28:19) at parser.next () at normalizeFile (node_modules/@babel/core/src/transformation/normalize-file.ts:50:24) at normalizeFile.next () at run (node_modules/@babel/core/src/transformation/index.ts:39:36) at run.next () at transform (node_modules/@babel/core/src/transform.ts:29:20) at transform.next () at evaluateSync (node_modules/gensync/index.js:251:28) at sync (node_modules/gensync/index.js:89:14) at fn (node_modules/@babel/core/src/errors/rewrite-stack-trace.ts:99:14) at transformSync (node_modules/@babel/core/src/transform.ts:66:52) at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:545:31) at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:674:40) at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:726:19) at node_modules/@seleniumhq/side-runtime/src/plugins.ts:34:34 at node_modules/@seleniumhq/side-runtime/src/plugins.ts:34:11 at async Promise.all (index 0) ● Test suite failed to run Jest encountered an unexpected token Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax. Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration. By default "node_modules" folder is ignored by transformers. Here's what you can do: • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it. • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config. • If you need a custom transformation specify a "transform" option in your config. • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option. You'll find more details and examples of these config options in the docs: https://jestjs.io/docs/configuration For information about custom transformations, see: https://jestjs.io/docs/code-transformation Details: SyntaxError: <>/nodejs/side/side-example-suite/dist/plugins/custom-click/index.ts: Missing initializer in const declaration. (9:12) 7 | */ 8 | 9 | const plugin: PluginShape = { | ^ 10 | commands: { 11 | customClick: { 12 | name: 'custom click', at constructor (node_modules/@babel/parser/src/parse-error.ts:74:19) at Parser.toParseError [as raise] (node_modules/@babel/parser/src/tokenizer/index.ts:1490:19) at Parser.raise [as parseVar] (node_modules/@babel/parser/src/parser/statement.ts:1550:16) at Parser.parseVar [as parseVarStatement] (node_modules/@babel/parser/src/parser/statement.ts:1196:10) at Parser.parseVarStatement [as parseStatementContent] (node_modules/@babel/parser/src/parser/statement.ts:550:21) at Parser.parseStatementContent [as parseStatementLike] (node_modules/@babel/parser/src/parser/statement.ts:421:17) at Parser.parseStatementLike [as parseModuleItem] (node_modules/@babel/parser/src/parser/statement.ts:358:17) at Parser.parseModuleItem [as parseBlockOrModuleBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1388:16) at Parser.parseBlockOrModuleBlockBody [as parseBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1362:10) at Parser.parseBlockBody [as parseProgram] (node_modules/@babel/parser/src/parser/statement.ts:217:10) at Parser.parseProgram [as parseTopLevel] (node_modules/@babel/parser/src/parser/statement.ts:199:25) at Parser.parseTopLevel [as parse] (node_modules/@babel/parser/src/parser/index.ts:45:10) at parse (node_modules/@babel/parser/src/index.ts:66:38) at parser (node_modules/@babel/core/src/parser/index.ts:28:19) at parser.next () at normalizeFile (node_modules/@babel/core/src/transformation/normalize-file.ts:50:24) at normalizeFile.next () at run (node_modules/@babel/core/src/transformation/index.ts:39:36) at run.next () at transform (node_modules/@babel/core/src/transform.ts:29:20) at transform.next () at evaluateSync (node_modules/gensync/index.js:251:28) at sync (node_modules/gensync/index.js:89:14) at fn (node_modules/@babel/core/src/errors/rewrite-stack-trace.ts:99:14) at transformSync (node_modules/@babel/core/src/transform.ts:66:52) at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:545:31) at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:674:40) at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:726:19) at node_modules/@seleniumhq/side-runtime/src/plugins.ts:34:34 at node_modules/@seleniumhq/side-runtime/src/plugins.ts:34:11 at async Promise.all (index 0) Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: 0.325 s, estimated 1 s Ran all test suites within paths "/usr/local/lib/node_modules/selenium-side-runner/dist/main.test.js".