-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
added code for frame example for python #2239
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
Conversation
👷 Deploy request for selenium-dev pending review.Visit the deploys page to approve it
|
PR Reviewer Guide 🔍
Here are some key observations to aid the review process:
Incorrect Frame Selection
Line 35 locates an iframe by NAME but line 36 uses the previously defined iframe variable instead of the newly located iframe1 variable, which could lead to unexpected behavior.
iframe1=driver.find_element(By.NAME, "iframe1-name") # (This line doesn't switch, just locates) driver.switch_to.frame(iframe)
Missing Test Structure
The file is structured as a script rather than proper test cases with assertions. Consider restructuring using pytest or unittest framework with proper setup/teardown methods.
#set chrome and launch web page driver = webdriver.Chrome() driver.get("https://www.selenium.dev/selenium/web/iframes.html") # --- Switch to iframe using WebElement --- iframe = driver.find_element(By.ID, "iframe1") driver.switch_to.frame(iframe) assert "We Leave From Here" in driver.page_source email_element = driver.find_element(By.ID, "email") email_element.send_keys("admin@selenium.dev") email_element.clear() driver.switch_to.default_content() # --- Switch to iframe using name or ID --- iframe1=driver.find_element(By.NAME, "iframe1-name") # (This line doesn't switch, just locates) driver.switch_to.frame(iframe) assert "We Leave From Here" in driver.page_source email = driver.find_element(By.ID, "email") email.send_keys("admin@selenium.dev") email.clear() driver.switch_to.default_content() # --- Switch to iframe using index --- driver.switch_to.frame(0) assert "We Leave From Here" in driver.page_source # --- Final page content check --- driver.switch_to.default_content() assert "This page has iframes" in driver.page_source #quit the driver driver.quit()
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||
putting this PR on hold.
created another PR after ensuring local environment is up to date.
#2240
Working on -#2240
Uh oh!
There was an error while loading. Please reload this page.
User description
Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.
Description
added code for frame example for python
Motivation and Context
added code for frame example for python
Types of changes
Checklist
PR Type
Enhancement, Documentation
Description
Added Python code example for iframe interactions in Selenium.
Updated documentation to reference the new Python example.
Replaced outdated Python code snippets with links to the new example.
Improved multilingual documentation consistency for iframe handling.
Changes walkthrough 📝
test_frames.py
Add Python iframe interaction example scriptexamples/python/tests/interactions/test_frames.py
frames.en.md
Update English iframe documentation with new Python examplewebsite_and_docs/content/documentation/webdriver/interactions/frames.en.md
frames.ja.md
Update Japanese iframe documentation with new Python examplewebsite_and_docs/content/documentation/webdriver/interactions/frames.ja.md
frames.pt-br.md
Update Portuguese iframe documentation with new Python examplewebsite_and_docs/content/documentation/webdriver/interactions/frames.pt-br.md
frames.zh-cn.md
Update Chinese iframe documentation with new Python examplewebsite_and_docs/content/documentation/webdriver/interactions/frames.zh-cn.md