nightwatch icon indicating copy to clipboard operation
nightwatch copied to clipboard

Add missing `isPresent` command in new Element API

Open garg3133 opened this issue 11 months ago • 14 comments

Description of the bug/issue

The isPresent command is currently missing from the new Element API. To support this command, a new file named isPresent.js needs to be added inside lib/api/web-element/commands directory, whose content should be similar to the get* command files present in the same directory.

The argument passed to this.runQueuedCommandScoped in these files is the name of the corresponding method to be called from the lib/transport/selenium-webdriver/method-mappings.js file. Currently, there's no such method so it needs to be created.

For the isPresent command, we just need to check whether the element is an instance of WebElement or ShadowRoot.

Steps to reproduce

Go to any test file present under examples/tests directory (ecosia.js and duckDuckGo.js are good examples to work with) and try to add const result = await browser.element('input[name=q]').isPresent() and then run the test (see contributing guide on how to run the example tests). This would result in an error right now, while if you replace isPresent() with getText(), it should work fine.

After adding the command implementation, the .isPresent() command should work fine.

TODO

  • [ ] Add missing command
  • [ ] Fix JSDoc of the command
  • [ ] Add tests for the new command
  • [ ] Add types for the new command

garg3133 avatar Feb 26 '24 16:02 garg3133

pls can i be assigned to work on this issue

aditya123473892 avatar Feb 26 '24 16:02 aditya123473892

@aditya123473892 I'll assign you this issue as soon as you come up with a potential solution for this issue. Feel free to open a PR.

garg3133 avatar Feb 26 '24 16:02 garg3133

hey @garg3133 do I have to create the function isElementPresent on method-mapping.js file also?

subhajit20 avatar Feb 26 '24 17:02 subhajit20

@subhajit20 You've already worked on similar PRs, it'd be better if you work on a different issue now. I'm creating these issues for beginners who are new to the project and not just to get them done.

I'll try to review your PRs tomorrow.

garg3133 avatar Feb 26 '24 17:02 garg3133

@subhajit20 You've already worked on similar PRs, it'd be better if you work on a different issue now. I'm creating these issues for beginners who are new to the project and not just to get them done.

I'll try to review your PRs tomorrow.

Cool, but still I have made a pr, if you will have time then check that once. Thanks!!

subhajit20 avatar Feb 26 '24 17:02 subhajit20

hey @garg3133 , I've completed the necessary changes. Could you please take some time to review them when you get a chance? I appreciate your feedback.

thanks!

Jai0401 avatar Feb 26 '24 19:02 Jai0401

It seems like a good first issue to try out and get used to the codebase. The guidelines provided seems very apt and precise but is the issue still open to PRs? Because quite a few PRs were raised so I am doubtful . It'd be very nice if you let me know @garg3133

AritraLeo avatar Mar 06 '24 10:03 AritraLeo

@garg3133 please have a look at my PR - https://github.com/nightwatchjs/nightwatch/pull/4098 linked to this issue.

AritraLeo avatar Mar 07 '24 15:03 AritraLeo

@garg3133 the test is passing in ecosia.js file after initializing nightwatch

AritraLeo avatar Mar 10 '24 06:03 AritraLeo

could i start working on this issue or this issue is already closed

Ankuristic avatar Mar 21 '24 02:03 Ankuristic

hey assign these issue to me and I will resolve these

Visbhavesh avatar Mar 25 '24 10:03 Visbhavesh

In order to discourage duplicate PRs on an issue, assigning this issue to @piyushmishra1416 since he is the first one to come up with a good PR which is very close to the solution. Also, adding @ansh21 as one of the reviewers of the PR to take the PR forward. @piyushmishra1416 please feel free to unassign yourself from the issue if you are no longer available to work on the PR.

Moving forward, we will only be reviewing PRs from the person to whom the issue is assigned.

garg3133 avatar Mar 28 '24 12:03 garg3133

hii @garg3133 is this issue still open i'd love to work on it

shubham-2909 avatar May 04 '24 11:05 shubham-2909

hello @garg3133 I would like to contribute and solve this bug, Please can you assign me this issue?

nikhil-babar avatar Jul 19 '24 13:07 nikhil-babar

hello @garg3133 sir is this issue still open ? As i would love to contribute to it.

sksingh2005 avatar Sep 13 '24 11:09 sksingh2005

Fixed in #4216. Thanks everyone!

garg3133 avatar Sep 13 '24 12:09 garg3133