Skip to content

Commit 242eb4d

Browse files
authored
Merge pull request #1274 from seleniumbase/iframe-methods-and-more
Iframe methods and more
2 parents 2dc6e2d + a6aab8c commit 242eb4d

File tree

9 files changed

+220
-49
lines changed

9 files changed

+220
-49
lines changed

examples/hack_the_planet.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
""" Video Link: https://youtu.be/1s-Tj65AKZA """
2-
from seleniumbase import __version__
32
from seleniumbase import BaseCase
43

54

65
class HackTests(BaseCase):
76
def test_all_your_base_are_belong_to_us(self):
8-
# First make sure that seleniumbase 1.65.0 or newer is installed
9-
version = __version__.split(".")
10-
if version[0] == "1" and int(version[1]) < 65:
11-
raise Exception(
12-
"This test requires minimum seleniumbase version: 1.65.0"
13-
)
147
self.set_window_size(1220, 740)
158
ayb = "ALL YOUR BASE"
169
abtu = "ARE BELONG TO US"

examples/offline_examples/test_demo_page.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ def test_demo_page(self):
2727

2828
# Verify that a hover dropdown link changes page text
2929
self.assert_text("Automation Practice", "h3")
30-
self.hover_and_click("#myDropdown", "#dropOption2")
30+
try:
31+
self.hover_and_click("#myDropdown", "#dropOption2", timeout=1)
32+
except Exception:
33+
# If someone moves the mouse while the test runs
34+
self.js_click("#dropOption2")
3135
self.assert_text("Link Two Selected", "h3")
3236

3337
# Verify that a button click changes text on the page

examples/proxy_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
class ProxyTests(BaseCase):
55
def test_proxy(self):
66
self.open("https://ipinfo.io/")
7-
ip_address = self.get_text("div.home-ip-details span.value")[1:-1]
7+
ip_address = self.get_text('#ip-string span[class*="primary"] span')
88
print("\n\nMy IP Address = %s\n" % ip_address)
99
print("Displaying Host Info:")
10-
text = self.get_text("div.home-ip-details").split("asn:")[0]
10+
text = self.get_text("#widget-scrollable-container").split("asn:")[0]
1111
rows = text.split("\n")
1212
data = []
1313
for row in rows:

examples/pure_python.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Running tests with pure "python" instead of directly calling "pytest".
2+
To run, use: "python pure_python.py".
3+
Two examples: pytest.main() and subprocess.call()."""
4+
import pytest
5+
import subprocess
6+
7+
pytest.main(["test_mfa_login.py", "--chrome", "-v"])
8+
subprocess.call(["pytest", "test_mfa_login.py", "--chrome", "-v"])

examples/test_iframes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ def test_iframe_basics(self):
88
self.assert_text("HTML Iframes", "h2")
99
self.switch_to_frame('[title*="Iframe"]') # Enter iframe inside iframe
1010
self.assert_text("This page is displayed in an iframe", "h1")
11-
self.switch_to_default_content() # Exit all iFrames
11+
self.switch_to_parent_frame() # Exit only the inner iframe
12+
self.assert_text("Use CSS width & height to specify", "p")
13+
self.switch_to_frame('[title*="Iframe"]') # Enter iframe inside iframe
14+
self.assert_text("seleniumbase.io/w3schools/iframes", "a")
15+
self.switch_to_default_content() # Exit all iframes
1216
self.click("button#runbtn")
1317
self.switch_to_frame("iframeResult") # Go back inside 1st iframe
1418
self.highlight('iframe[title="Iframe Example"]')
@@ -20,7 +24,7 @@ def test_set_content_to_frame(self):
2024
self.set_content_to_frame("iframe")
2125
self.assert_element_not_visible("iframe")
2226
self.highlight("body")
23-
self.set_content_to_default(nested=False)
27+
self.set_content_to_parent()
2428
self.highlight('iframe[title="Iframe Example"]')
2529
self.set_content_to_default()
2630
self.click("button#runbtn")

help_docs/method_summary.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,15 @@ self.switch_to_frame(frame, timeout=None)
207207

208208
self.switch_to_default_content()
209209

210+
self.switch_to_parent_frame()
211+
210212
self.set_content_to_frame(frame, timeout=None)
211213

212-
self.set_content_to_default(nested=True)
214+
self.set_content_to_default(nested=False)
215+
# Duplicates: self.set_content_to_default_content(nested=False)
216+
217+
self.set_content_to_parent()
218+
# Duplicates: self.set_content_to_parent_frame()
213219

214220
self.open_new_window(switch_to=True)
215221
# Duplicates: self.open_new_tab(switch_to=True)

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "2.4.33"
2+
__version__ = "2.4.34"

0 commit comments

Comments
 (0)