seleniumhq.github.io
seleniumhq.github.io copied to clipboard
Fix for #1333 | Python alert automation
Description
This PR fixes issue #1333
Motivation and Context
Bug fix and contribution to Selenium community 🎉
Types of changes
- [ ] Change to the site (I have double-checked the Netlify deployment, and my changes look good)
- [ ] Code example added (and I also added the example to all translated languages)
- [ ] Improved translation
- [ ] Added new translation (and I also added a notice to each document missing translation)
- [x] Bug Fix
Checklist
- [x] I have read the contributing document.
- [ ] I have used hugo to render the site/docs locally and I am sure it works.
Deploy request for selenium-dev pending review.
Visit the deploys page to approve it
| Name | Link |
|---|---|
| Latest commit | 3d7a02721fbf849b4ec7693541fd0b172e937043 |
First, thanks for the PR.
The intention of the code here is not to thoroughly test a page, but to provide examples that can be displayed here: https://www.selenium.dev/documentation/webdriver/interactions/alerts/#alerts
So we only need 3 working examples that we can link to, and they should be complete examples instead of abstracting out the common pieces. The point is to look at the complete method.
Finally, I'm confused about the sleeps. We shouldn't need to hard code sleeps. Is the Python Selenium code not doing what we expect it to?
First, thanks for the PR.
The intention of the code here is not to thoroughly test a page, but to provide examples that can be displayed here: https://www.selenium.dev/documentation/webdriver/interactions/alerts/#alerts
So we only need 3 working examples that we can link to, and they should be complete examples instead of abstracting out the common pieces. The point is to look at the complete method.
Finally, I'm confused about the sleeps. We shouldn't need to hard code sleeps. Is the Python Selenium code not doing what we expect it to?
Sure, I can update the PR.
How about 3 examples, like this one ( I used this Alert example )
# Click the link to activate the alert
driver.find_element(By.ID, "alert").click()
# Store the alert in a variable
alert = driver.switch_to.alert
# Store the alert text in a variable
text = alert.text
#assert alert text
assert alert.text == "cheese"
# Press the OK button
alert.accept()
On
We shouldn't need to hard code sleeps.
It was the Alert pop up from browser that was taking time when I was hitting all the alert links. If I am putting 3 basic examples, hardcoded sleep is not required and works fine.
Done ✅
@titusfortner, ready for review.
That test gets fixed by #1472
But also, we want to run these with pytest in our CI, so we want to put these into their own test methods.
- Please remove the comments, we want the comments to be in the docs (so they can be translated) not in the code.
- The convention we're using is to have 3 separate tests to match these 3: https://www.selenium.dev/documentation/webdriver/interactions/alerts/
- We want to then take the code you've written and reference it in the alerts md file. We want to remove all of this: https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/website_and_docs/content/documentation/webdriver/interactions/alerts.en.md?plain=1#L43-L53
and replace it with this:
{{< gh-codeblock path="examples/python/tests/interactions/test_alerts.py#LXX-LYY" >}}
- Finally we're looking to copy that block of code in the en file to the other translation markdown files as well.
If you want to discuss or collaborate, come find us in the #selneium-docs channel in the chat room: https://www.selenium.dev/support/#ChatRoom
This went stale, closing.