Skip to content

Commit 6ad88d3

Browse files
mdmintzsymonkdiemol
authored
Fix frame_to_be_available_and_switch_to_it() for string inputs (#10967)
* Fix frame_to_be_available_and_switch_to_it() for string inputs * Add new test for frame_to_be_available_and_switch_to_it() * Version 4.4.4 * Update Python CHANGES for version 4.4.4 * Use `not isinstance(locator, str)` instead of `type(locator) is not str` * Skip the version change for now Co-authored-by: Simon K <[email protected]> Co-authored-by: Diego Molina <[email protected]>
1 parent ce2ee20 commit 6ad88d3

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

py/CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Selenium (TBA next version)
2+
* Fix frame_to_be_available_and_switch_to_it() for string inputs (#10963)
3+
14
Selenium 4.4.3
25
* Update explicit dependency for certifi to remove upper bound (#10956)
36

py/selenium/webdriver/support/expected_conditions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def frame_to_be_available_and_switch_to_it(locator):
252252

253253
def _predicate(driver):
254254
try:
255-
if hasattr(locator, '__iter__'):
255+
if hasattr(locator, '__iter__') and not isinstance(locator, str):
256256
driver.switch_to.frame(driver.find_element(*locator))
257257
else:
258258
driver.switch_to.frame(locator)

py/test/selenium/webdriver/common/frame_switching_tests.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,22 @@ def test_should_be_able_to_switch_to_the_top_if_the_frame_is_deleted_from_under_
351351
WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.ID, "success")))
352352

353353

354+
def test_frame_to_be_available_and_switch_to_it_using_string_inputs(driver, pages):
355+
# Similar to above test, but using `iframe = "iframe1"` instead of `iframe = 0`
356+
pages.load("frame_switching_tests/deletingFrame.html")
357+
iframe = "iframe1"
358+
WebDriverWait(driver, 3).until(EC.frame_to_be_available_and_switch_to_it(iframe))
359+
# we should be in the frame now
360+
killIframe = driver.find_element(By.ID, "killIframe")
361+
killIframe.click()
362+
driver.switch_to.default_content()
363+
364+
addIFrame = driver.find_element(By.ID, "addBackFrame")
365+
addIFrame.click()
366+
WebDriverWait(driver, 3).until(EC.frame_to_be_available_and_switch_to_it(iframe))
367+
WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.ID, "success")))
368+
369+
354370
def test_should_be_able_to_switch_to_the_top_if_the_frame_is_deleted_from_under_us_with_webelement(driver, pages):
355371
pages.load("frame_switching_tests/deletingFrame.html")
356372
iframe = driver.find_element(By.ID, "iframe1")

0 commit comments

Comments
 (0)