seleniumhq.github.io icon indicating copy to clipboard operation
seleniumhq.github.io copied to clipboard

Fix for #1333 | Python alert automation

Open eaccmk opened this issue 2 years ago • 7 comments

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.

eaccmk avatar Sep 09 '23 04:09 eaccmk

Deploy request for selenium-dev pending review.

Visit the deploys page to approve it

Name Link
Latest commit 3d7a02721fbf849b4ec7693541fd0b172e937043

netlify[bot] avatar Sep 09 '23 04:09 netlify[bot]

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?

titusfortner avatar Sep 09 '23 19:09 titusfortner

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.

eaccmk avatar Sep 11 '23 00:09 eaccmk

Done ✅
@titusfortner, ready for review.

eaccmk avatar Sep 12 '23 04:09 eaccmk

That test gets fixed by #1472

titusfortner avatar Sep 13 '23 13:09 titusfortner

But also, we want to run these with pytest in our CI, so we want to put these into their own test methods.

titusfortner avatar Sep 13 '23 14:09 titusfortner

  • 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

titusfortner avatar Sep 15 '23 01:09 titusfortner

This went stale, closing.

diemol avatar Jun 18 '25 13:06 diemol