Skip to content

DemoAlerts() - show that prompt was set #371

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

Merged
merged 6 commits into from
Aug 10, 2022

Conversation

mlipok
Copy link
Contributor

@mlipok mlipok commented Aug 8, 2022

Pull request

Proposed changes

this PR is only related to the comment that describe in the specific case what kind of expected result should be to check Alert status

Checklist

  • 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

  • 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?

; check status before displaying Alert

What is the new behavior?

; check status before displaying Alert - this should set @error as there is no any Alert displayed yet

Additional context

I was checking examples for this ISSUE #254

System under test

not related

@mlipok mlipok changed the title DemoAlerts() - comments suplemented DemoAlerts() - added dismiss example Aug 8, 2022
@mlipok
Copy link
Contributor Author

mlipok commented Aug 8, 2022

I have some further refactoring for this DemoAlerts().
WIP

@Danp2 Danp2 marked this pull request as draft August 8, 2022 13:34
@mlipok mlipok changed the title DemoAlerts() - added dismiss example DemoAlerts() - using Storage to show that prompt was set Aug 8, 2022
@mlipok mlipok marked this pull request as ready for review August 8, 2022 13:42
@mlipok
Copy link
Contributor Author

mlipok commented Aug 8, 2022

As for me it is all in this PR, please review again and merge if you agree with my opinion about the comments:

The main point of the status option is to return either True or False. Wouldn't it be better to explain that?

If we change error handling then the comments change in this regards is not needed as there is already status reported to console

$sStatus = _WD_Alert($sSession, 'status')
ConsoleWrite("wd_demo.au3: (" & @ScriptLineNumber & ") : " & 'Alert Detected => ' & $sStatus & @CRLF)

@Danp2
Copy link
Owner

Danp2 commented Aug 8, 2022

using Storage to show that prompt was set

Why is this needed here? I don't see the purpose of using "storage" in the middle of an Alerts demo.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 8, 2022

To show that the given text entered to prompt was properly send to browser.

@Danp2
Copy link
Owner

Danp2 commented Aug 8, 2022

Sorry, but I don't understand how this code demonstrates that. With this line --

_WD_ExecuteScript($sSession, "window.localStorage.setItem('testing',prompt('User Prompt 1', 'Default value'))")

you introduce advanced concepts that have nothing to do with _WD_Alert IMO.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 8, 2022

Yes it is more advanced than only showing prompt.
Because in order to check if ti was properly set by prompt it stores the value in webbrowser and then we check the stored value using _WD_Storage($sSession, 'testing')

@Danp2
Copy link
Owner

Danp2 commented Aug 8, 2022

I've run the revised demo, but I still don't get the point of this change. You are storing and retrieving the value that was changed with _WD_ExecuteScript, not _WD_Alert. Therefore, I don't see the added value here. 🤔

@mlipok
Copy link
Contributor Author

mlipok commented Aug 8, 2022

this part:

au3WebDriver/wd_demo.au3

Lines 531 to 532 in a41396b

; show Prompt for testing
_WD_ExecuteScript($sSession, "window.localStorage.setItem('testing',prompt('User Prompt 1', 'Default value'))")

popup prompt to input data, which are saved in browser Storage

and this part:

au3WebDriver/wd_demo.au3

Lines 542 to 544 in a41396b

; check if new value was properly sent to browser (in this case saved in browser Storage)
Local $sStorage = _WD_Storage($sSession, 'testing')
ConsoleWrite("wd_demo.au3: (" & @ScriptLineNumber & ") : " & '$sStorage => ' & $sStorage & @CRLF)

check what trully was received and save in browser Storage

I call this validation.

EDIT:
By the way, it also shows how Storage can be used.

@Danp2
Copy link
Owner

Danp2 commented Aug 8, 2022

I call this validation.

AFAICS you aren't validating the functionality of _WD_Alert. Therefore, this doesn't belong in DemoAlerts function.

By the way, it also shows how Storage can be used.

Also doesn't belong here.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 9, 2022

AFAICS you aren't validating the functionality of _WD_Alert. Therefore, this doesn't belong in DemoAlerts function.

So how we can validate that

var userinput = prompt('User Prompt 1', 'Default value')

browser get the value provided by entering string to the prompt ?

@Danp2
Copy link
Owner

Danp2 commented Aug 9, 2022

You need a webpage that accepts the user input and then displays it on screen like they do here. I haven't tried this yet, but I was thinking that you could open a new tab and then use _WD_ExecuteScript to update the tab's source code to mimic the behavior of that website without the frames.

@mlipok
Copy link
Contributor Author

mlipok commented Aug 9, 2022

Why not simply use this webpage ?
https://www.quanzhanketang.com/jsref/tryjsref_prompt.html?filename=tryjsref_prompt

@Danp2 Danp2 changed the title DemoAlerts() - using Storage to show that prompt was set DemoAlerts() - show that prompt was set Aug 10, 2022
@Danp2 Danp2 merged commit 62260cc into Danp2:master Aug 10, 2022
@mlipok mlipok deleted the ml_DemoAlerts_comments branch August 11, 2022 08:56
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