Skip to content

Conversation

@JonahStanley
Copy link
Contributor

Suggested Reviewers @wedaly @cahrens @jzoldak

In this pull request, I have fixed the issue of chrome hanging on alerts.

This was done by changing how alerts work on the javascript level:
Alerts are created through window.alert(), window.confirm(), window.prompt()
These methods have some functionality that creates the popup box and upon the user clicking/typing either return (alert), return true or false (confirm) or return with a string (prompt)

Selenium can inject javascript through world.browser.execute_script()
Now, there are steps to cut out the middleman so to speak.
"I confirm all alerts" will redefine
window.alert = function(){return;}
window.confirm = function(){return true;}

"I dismiss all alerts" will redefine
window.confirm = function(){return false;}

'I answer all prompts with "([^"]*)"' will redefine
window.prompt = function(){return %s} %prompt

The window variable only persists on a given page so changing these functions will only affect the page they are on. While this does make it safer to modify these functions, this also means that these steps must be called right before the alert is generated.

In following this, I have also fixed the features that required this functionality and they all now work on my local machine.

JonahStanley added 2 commits June 5, 2013 15:08
This is done with the following steps:
'I confirm all alerts' means that all alert and confirm windows are returned and returned true respectively
'I dismiss all alerts' means that all confirm windows are returned false
'I answer all prompts with "([^"]*)"' means that all prompts are returned with the given string

Please note that these settings are on a PER PAGE basis.  This means that for best results, the step must be given right before the alert is generated.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some indenting issues. Perhaps the file needs to be reindented to remove tabs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats weird... the file looks fine on my local version and git is telling me that I don't have any more changes to commit so I am not sure how to fix that

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified the file does not have a mix of tabs and spaces? We don't want tabs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason it loaded as tabs. Changing that now and recommitting

@cahrens
Copy link

cahrens commented Jun 5, 2013

It's a little awkward to read, with the confirming happening before you actually do the action that prompts the alert. Perhaps change the steps to read "I will confirm all alerts"?

@cahrens
Copy link

cahrens commented Jun 5, 2013

👍 (thought tests have not finished running). Note that I did NOT check out the branch and try running the tests myself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the wording of this is necessarily a bit awkward because of the way it needs to be used, can you please include docstrings for these three "I will" methods? Something about how you need to put the statements about the behavior wanted when dismissing alerts before the statement that will trigger an alert to be popped up?

@jzoldak
Copy link
Contributor

jzoldak commented Jun 6, 2013

Please include the in-code documentation noted above, then 👍

@wedaly
Copy link
Contributor

wedaly commented Jun 6, 2013

👍 Looks good to me

JonahStanley pushed a commit that referenced this pull request Jun 6, 2013
@JonahStanley JonahStanley merged commit a3a7d1d into master Jun 6, 2013
@JonahStanley JonahStanley deleted the jonahstanley/fix-alert-tests branch June 6, 2013 19:59
aboudreault pushed a commit to aboudreault/edx-platform that referenced this pull request Jun 11, 2014
…eapiview-fix

Mattdrayer/api secureapiview fix Tested - seemed to fix the right stuff for us!
symbolist pushed a commit that referenced this pull request Mar 23, 2016
Release Candidate rc/2016-03-22
prabhanshu pushed a commit to prabhanshu/edx-platform that referenced this pull request Oct 13, 2018
prabhanshu pushed a commit to prabhanshu/edx-platform that referenced this pull request Oct 13, 2018
francisfueconcillo pushed a commit to apifirstsolutions/edx-platform that referenced this pull request Jun 21, 2021
Remove code added for Debugging purpose

Approved-by: nyein.eizaw
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.

5 participants