Danp2 / au3WebDriver

Web Driver UDF for AutoIt
MIT License
107 stars 23 forks source link

_WD_ElementSelectAction should validate Multiselect request #368

Closed Danp2 closed 2 years ago

Danp2 commented 2 years ago

Bug report

Describe the bug

There is currently no validation taking place when executing the Multiselect option of _WD_ElementSelectAction

How to reproduce

Steps to reproduce the behavior (e.g.):

Local $a_Printer[] = ['Save as PDF']
_WD_ElementSelectAction($WD_SESSION, $sSelectElement, "MULTISELECT", $a_Printer)

See link below for full context

Expected behavior

Function should verify that that calling routine supplied multiple options to match. Also, the Select element should be queried for multiselect capability and return an error if it isn't.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/?do=findComment&comment=1505272

System under test

Please complete the following information.

mlipok commented 2 years ago

Function should verify that that calling routine supplied multiple options to match.

I plan to handle this issue in https://github.com/Danp2/au3WebDriver/pull/367

mlipok commented 2 years ago

Also, the Select element should be queried for multiselect capability and return an error if it isn't.

In case of error should any selecting/dispatch action should be taken on <select> element ? What kind of error you propose ?

Danp2 commented 2 years ago

In case of error should any selecting/dispatch action should be taken on select element?

No. This validation should take place before performing any other actions.

What kind of error you propose ?

I haven't thought about it TBH. Perhaps $_WD_ERROR_InvalidArgue or $_WD_ERROR_ElementIssue.

mlipok commented 2 years ago

$_WD_ERROR_ElementIssue sounds better.

mlipok commented 2 years ago

https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/?do=findComment&comment=1505272

this discussion has pointed out a few weak points with the current "multiselect" implementation --

No validation that the target select element supports multiselect
No validation that multiple selections were requested

It is suplemented here: _WD_ElementSelectAction + SINGLESELECT #367

https://github.com/Danp2/au3WebDriver/blob/bf1c64807eab2130e27f685a2d59be6c49e6fd9f/wd_helper.au3#L1030-L1032

and here: https://github.com/Danp2/au3WebDriver/blob/bf1c64807eab2130e27f685a2d59be6c49e6fd9f/wd_helper.au3#L1065-L1067

Danp2 commented 2 years ago

Enforced minimum of two options for multiSelect here -- https://github.com/Danp2/au3WebDriver/blob/9122d4fb2825f9aefa515a9cbc0e96e98fbe2b23/wd_helper.au3#L1052

mlipok commented 2 years ago

selectAll should do the same (validate SelectElement.multiple == false ) I will make separate PR

mlipok commented 2 years ago

Enforced minimum of two options for multiSelect here --

https://github.com/Danp2/au3WebDriver/blob/9122d4fb2825f9aefa515a9cbc0e96e98fbe2b23/wd_helper.au3#L1052

reverted: https://github.com/Danp2/au3WebDriver/pull/367#discussion_r942347772

mlipok commented 2 years ago

selectAll should do the same (validate SelectElement.multiple == false ) I will make separate PR

https://github.com/Danp2/au3WebDriver/pull/373