zaproxy / zest

Mozilla Public License 2.0
102 stars 36 forks source link

added mouseover, resize and scroll #244

Closed aryangupta701 closed 1 year ago

aryangupta701 commented 1 year ago

Fix #243

Added mouseover, resize and scroll methods to handle hovering, resizing window and scrolling.

aryangupta701 commented 1 year ago

@psiinon Please guide me how can I test the behaviour of the newly added methods? I am not sure weather this will work or not.

psiinon commented 1 year ago

Sure :) The way I would do it is to:

  1. create a suitable test page
  2. write a simple Zest script in ZAP which interacts with it in a basic way
  3. run it in ZAP (to make sure it works)
  4. save the script
  5. run it from the command line (this is to make sure everything is still ok)
  6. add one of the new statements which will do something detectable
  7. run the script again from the cmdline - you should see the effect
  8. repeat for the other statements
aryangupta701 commented 1 year ago

okay thank you.

thc202 commented 1 year ago

Also worth looking at the codebase (e.g. ZestClientScreenshotUnitTest) to add unit tests.

aryangupta701 commented 1 year ago

how can I run the script from the command line ?

psiinon commented 1 year ago

Theres https://github.com/zaproxy/zest/wiki/Commandline but I havnt tried it in a while - give it a go and let us know if you have any problems...

aryangupta701 commented 1 year ago

I have tested it manually and it is working as expected. I am not able to understand what kind of unit test will it need to be written. Please guide me through it. I have seen ZestClientScreenshotUnitTest but still not sure about what kind of tests are needed.

thc202 commented 1 year ago

The tests you did manually do them automatically :) If that's not possible verify that at least the expected classes are called, other behaviour than the invoke itself should be tested as well.

Edit: To be clear I do think that all 3 statements being added can be tested automatically.

aryangupta701 commented 1 year ago

Thankyou @thc202

aryangupta701 commented 1 year ago

@thc202 I have written test for scrolling as of now. Please check if I went into the right direction, then I will write for others as well.

psiinon commented 1 year ago

@aryangupta701 - looking good so far, let us know when its ready to review again.

aryangupta701 commented 1 year ago

okay sure.

aryangupta701 commented 1 year ago

I do think that these methods along with already present methods will be sufficient to handle all the user interactions. If you think I am missing something please tell me.

thc202 commented 1 year ago

https://github.com/zaproxy/zest/pull/244#issuecomment-1483879548

IMO a scroll to statement would be easier to use in most cases (though the scroll element might still be useful/needed in some cases).

https://github.com/zaproxy/zest/pull/244#issuecomment-1460839256

This one was not yet addressed, the invoke methods are not being tested.

aryangupta701 commented 1 year ago

ok will add a scrollTo statement also

aryangupta701 commented 1 year ago

I tried automating the test for invoke functionality using mockito but was encountering some problems. For eg: at one place I have used new keyword instantiate Actions but it is not possible to mock new using mockito for this I will have to use powerMockito. If there is any other solution please guide me.

thc202 commented 1 year ago

You don't need to mock the Actions, you have both the WebDriver and the WebElement to verify the interactions. If that's too much work you can run the actual statement (e.g. ZestClientLaunchUnitTest.testHtmlUnitLaunch()) and verify the outcome.

aryangupta701 commented 1 year ago

okay thanks. Will I need to create a test website to test mouseover statement?

thc202 commented 1 year ago

Yes, you can serve static data like done in the test mentioned earlier (e.g. check before method and ServerBasedTest).

aryangupta701 commented 1 year ago

okay.

aryangupta701 commented 1 year ago

@thc202 Could you please review and tell me if anything needs to be changed?

thc202 commented 1 year ago

Thank you!