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

_WD_ElementSelectAction + SINGLESELECT #367

Conversation

mlipok
Copy link
Contributor

@mlipok mlipok commented Aug 5, 2022

Pull request

Proposed changes

This PR add feature to easily select single <option> element by its label

Checklist

Put an x in the boxes that apply. If you're unsure about any of them, don't hesitate to ask. We are here to help!

This is simply a reminder of what we are going to look for before merging your code.

  • I have read and noticed the CODE OF CONDUCT document
  • I have read and noticed the CONTRIBUTING document
  • I have added necessary documentation or screenshots (if appropriate)

Types of changes

Please check x the type of change your PR introduces:

  • Bugfix (change which fixes an issue)
  • Feature (change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (functional, structural)
  • Documentation content changes
  • Other (please describe)

What is the current behavior?

no way for easy way to select single option by LabelName

What is the new behavior?

can be easily done with

_WD_ElementSelectAction($sSesion, $sSelectElement, 'singleLabel', 'LabelNameToSeclect')

Additionally _WD_ExecuteScript currently returns true or false as JavaScript was refactored

JavaScript code was refactored to use functions because this is easier to copy them to browser and test and maintain in the future.

JavaScript code is stored as static value which optimize speed of AutoIt execution in case of using this function multiple times.

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

Additional context

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

#368 (comment)

System under test

not related

@mlipok mlipok marked this pull request as ready for review August 5, 2022 16:54
@Danp2
Copy link
Owner

Danp2 commented Aug 6, 2022

singleLabel seems like an odd choice for this option's name. singleSelect would make more sense to me given that we already have multiSelect

@Danp2
Copy link
Owner

Danp2 commented Aug 6, 2022

Additionally _WD_ExecuteScript currently returns true or false as JavaScript was refactored

No idea what you are trying to say here

JavaScript code was refactored to use functions because this is easier to copy them to browser and test and maintain in the future.

That's fine. I'm assuming that you've tested your changes to be sure that the code continues to work as before. 🤨

@mlipok mlipok changed the title _WD_ElementSelectAction + SINGLELABEL _WD_ElementSelectAction + SINGLESELECT Aug 6, 2022
@mlipok mlipok marked this pull request as draft August 6, 2022 19:38
@mlipok
Copy link
Contributor Author

mlipok commented Aug 6, 2022

Additionally _WD_ExecuteScript currently returns true or false as JavaScript was refactored

No idea what you are trying to say here

recently JS was returning only return true there was not return false; point in the JS.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 6, 2022

JavaScript code was refactored to use functions because this is easier to copy them to browser and test and maintain in the future.

That's fine. I'm assuming that you've tested your changes to be sure that the code continues to work as before.

on my own website yes.
Before I request review I will proceed further test with DemoSelectOptions

btw.
This was one of the reason I changed this PR to draft.
The other one is #368 (comment)

@mlipok mlipok marked this pull request as ready for review August 7, 2022 21:22
@mlipok
Copy link
Contributor Author

mlipok commented Aug 7, 2022

checked with: DemoSelectOptions() refactoring + new features

btw:
also updated status in: wd_demo: review all "Demo****" function

wd_helper.au3 Outdated Show resolved Hide resolved
wd_helper.au3 Outdated Show resolved Hide resolved
wd_helper.au3 Outdated Show resolved Hide resolved
@mlipok
Copy link
Contributor Author

mlipok commented Aug 10, 2022

as to: added waschanged
in this following code

au3WebDriver/wd_helper.au3

Lines 1018 to 1028 in 1d585c0

" if ( (LabelsToSelect.indexOf(o.label)!= -1)" & _
" && (o.disabled==false && (!(o.parentNode.nodeName =='OPTGROUP' && o.parentNode.disabled)))" & _
" && (o.hidden==false && (!(o.parentNode.nodeName =='OPTGROUP' && o.parentNode.hidden)))" & _
" ) {" & _
" o.selected = true;" & _
" result = true;" & _
" waschanged = true;" & _
" } else if (DeselectingNonListedLabels) {" & _
" o.selected = false;" & _
" waschanged = true;" & _
" };" & _

can be a case when element is disabled or hidden and in case when DeselectingNonListedLabels parameter was set then also waschanged will be set

I think that disabled or hidden should not be touched in any case.
What is your opinion in this regrad?

wd_demo.au3 Outdated Show resolved Hide resolved
@Danp2
Copy link
Owner

Danp2 commented Aug 13, 2022

I think that disabled or hidden should not be touched in any case.
What is your opinion in this regrad?

Did you consider issuing the command SelectElement.selectedIndex = -1; to deselect all options before selecting the designated options?

@Danp2 Danp2 changed the base branch from master to dp_WD_ElementSelectAction August 15, 2022 15:00
@mlipok
Copy link
Contributor Author

mlipok commented Aug 15, 2022

Did you consider issuing the command SelectElement.selectedIndex = -1; to deselect all options before selecting the designated options?

In this scenario we will have problem that selecting the single <option> will always occurs and always event should be fired.

@Danp2
Copy link
Owner

Danp2 commented Aug 15, 2022

In this scenario we will have problem that selecting the single will always occurs and always event should be fired.

Isn't that already occurring here because DeselectingNonListedLabels is True?

au3WebDriver/wd_helper.au3

Lines 1025 to 1028 in 1d585c0

" } else if (DeselectingNonListedLabels) {" & _
" o.selected = false;" & _
" waschanged = true;" & _
" };" & _

wd_helper.au3 Show resolved Hide resolved
@mlipok
Copy link
Contributor Author

mlipok commented Aug 16, 2022

Isn't that already occurring here because DeselectingNonListedLabels is True?

fixed here: DeselectingNonListedLabels > AllowMultiple

wd_helper.au3 Outdated Show resolved Hide resolved
@mlipok
Copy link
Contributor Author

mlipok commented Aug 16, 2022

As for me all is OK

@Danp2 Danp2 merged commit 89fe1c1 into Danp2:dp_WD_ElementSelectAction Aug 16, 2022
@mlipok mlipok deleted the ml__WD_ElementSelectAction_SINGLELABEL branch August 16, 2022 18:36
Danp2 added a commit that referenced this pull request Aug 22, 2022
* _WD_ElementSelectAction 'selectedOptions' group (#375)
* _WD_ElementSelectAction 'options' added group name (#374)
* _WD_ElementSelectAction 'selectAll' JS validation (#373)
* _WD_ElementSelectAction 'selectedLabels' JS refact (#376)
* _WD_ElementSelectAction + SINGLESELECT (#367)
* _ElementSelectAction : JS refactoring + case insensivity (#381)
* Return result from `selectAll`
* selectAll + $_WD_ERROR_NoMatch
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.

2 participants