getgauge / taiko

A node.js library for testing modern web applications
https://taiko.dev
MIT License
3.55k stars 450 forks source link

.api with the name of the api should have all detailed information #834

Closed Debashis9012 closed 4 years ago

Debashis9012 commented 4 years ago

Expected behavior

.api "api name" should have all detailed information.

Ex: .api inputField As we have deprecated inputField api to textBox, it should show the deprecation message.

It should have parameters, deprecation note, return type for an api. Its better to have these information which will be useful for the user.

Actual behavior

> .api inputField

This selector lets you identify an input field on a web page with label or attribute and value pairs and proximity selectors.

Example:
    await focus(inputField({'id':'name'})
    await inputField({'id': 'name'}).exists()
    await inputField({id:'inputFieldId'},below('text')).exists()
    await inputField(below('text')).exists()

Versions

Version: 1.0.2 (Chromium: 76.0.3803.0) c9fdf2959cce1b94e6ed6964aecaca505c5cf43d
Mark1626 commented 4 years ago

I'm working on a PR for this.

Mark1626 commented 4 years ago

DEPRECATED: use textBox for input with type text and password, textarea and contenteditable fields.

This selector lets you identify an input field on a web page with label or attribute and value pairs and proximity selectors.

Returns:    ElementWrapper

Parameters:
┌─────────┬──────────────────┬───────────────────────┬─────────┐
│ (index) │       Name       │         Type          │ Default │
├─────────┼──────────────────┼───────────────────────┼─────────┤
│    0    │ 'attrValuePairs' │       'Object'        │   ''    │
│    1    │      'args'      │ '...relativeSelector' │   ''    │
└─────────┴──────────────────┴───────────────────────┴─────────┘

Example:
    await focus(inputField({'id':'name'})
    await inputField({'id': 'name'}).exists()
    await inputField({id:'inputFieldId'},below('text')).exists()
    await inputField(below('text')).exists()

Current I've implemented in this order

And I've used console.table to format the parameters.

nehashri commented 4 years ago

@M4rk9696 I think the order should be

Also, I quite don't like the table format for the parameters. I think it will not be that readable when you have nested parameter values. I vote to keep it as a simple list similar to what is there on the documentation.

Mark1626 commented 4 years ago

What about this? The problem is the long description of the param. There is no way for a user to distinguish between param name, type and description

> .api openBrowser

Launches a browser with a tab. The browser will be closed when the parent node.js process is closed. <br> Note : openBrowser launches the browser in headless mode by default, but when openBrowser is called from repl it launches the browser in headful mode.

Parameter:

* options - Object
     eg. {headless: true|false, args:  } (optional, default {headless:true})
  * options.headless - boolean
     Option to open browser in headless/headful mode. (optional, default true)
  * options.args - Array<string>
     Args to open chromium. Refer https://peter.sh/experiments/chromium-command-line-switches/ for values. (optional, default [])
  * options.host - string
     Remote host to connect to. (optional, default '127.0.0.1')
  * options.port - number
     Remote debugging port, if not given connects to any open port. (optional, default 0)
  * options.ignoreCertificateErrors - boolean
     Option to ignore certificate errors. (optional, default false)
  * options.observe - boolean
     Option to run each command after a delay. Useful to observe what is happening in the browser. (optional, default false)
  * options.observeTime - number
     Option to modify delay time for observe mode. Accepts value in milliseconds. (optional, default 3000)
  * options.dumpio - boolean
     Option to dump IO from browser. (optional, default false)

Returns: Promise

Example:
    await openBrowser({headless: false})
    await openBrowser()

I'll raise a draft WIP PR and iterate from there.

Debashis9012 commented 4 years ago

.api with the api name gives the results as per the above changes. Tested version: Version: 1.0.2 (Chromium: 76.0.3803.0) 9b0b3fc46c78e2596c9dad34e9a0ce69abf3be30