Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types for custom commands on page object sections. #4298

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

garg3133
Copy link
Member

Fixes: #4292

This PR adds the types for the custom commands that are made available directly over the page object sections.

It should be noted NOT all custom commands are made available directly on the section object. All the custom commands are only available on the section.api object while the section object directly contains all the custom commands EXCEPT those having a namespace. This behaviour has been accounted for in the type definition.

For example, let's say the structure of the custom-commands folder is as follows:

custom-commands/
  - command1.js
  - command2.js
  - namespace1/
      - command.js

The above custom commands would be available on the various APIs as follows (assuming a page-object named myPage with a mySection section):

// all commands are available on the `browser` object
browser.command1();
browser.command2();
browser.namespace1.command(); // WORKS

// only non-namespaced custom commands are available on the `mySection` object directly
const mySection = myPage.section.mySection;

mySection.api.command1();
mySection.command2();
mySection.namespace1.command(); // !!!ERROR

// all commands are available on the `mySection.api` object
mySection.api.command1();
mySection.command2();
mySection.namespace1.command();  // WORKS

The above is also true for the page-objects -- only non-namespaced custom commands are made directly available on the page object.

The types for custom commands on page-objects should also be fixed at some later time (after making sure that the newly added type definition is working correctly).

@garg3133 garg3133 merged commit af6975f into nightwatchjs:main Nov 11, 2024
16 of 17 checks passed
@garg3133 garg3133 deleted the fix-4292 branch November 11, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement NightwatchCustomCommands for EnhancedSectionInstance
1 participant