|
| 1 | +import pytest |
| 2 | +from selenium.webdriver import Firefox |
| 3 | +from selenium.webdriver.common.keys import Keys |
| 4 | + |
| 5 | +from modules.browser_object import TabBar |
| 6 | + |
| 7 | + |
| 8 | +@pytest.fixture() |
| 9 | +def test_case(): |
| 10 | + return "134640" |
| 11 | + |
| 12 | + |
| 13 | +URLS = [ |
| 14 | + "about:about", |
| 15 | + "about:addons", |
| 16 | + "about:cache", |
| 17 | + "about:robots", |
| 18 | +] |
| 19 | + |
| 20 | + |
| 21 | +def test_reopen_tabs_through_keys(driver: Firefox, sys_platform: str): |
| 22 | + """ |
| 23 | + C134640 - Verify that previously closed tabs can be reopened using |
| 24 | + the keyboard shortcut (Ctrl/Cmd + Shift + T). |
| 25 | + """ |
| 26 | + |
| 27 | + tabs = TabBar(driver) |
| 28 | + |
| 29 | + # Create 4 new tabs |
| 30 | + for i in range(4): |
| 31 | + tabs.new_tab_by_button() |
| 32 | + driver.switch_to.window(driver.window_handles[-1]) |
| 33 | + driver.get(URLS[i]) |
| 34 | + assert len(driver.window_handles) == 5 |
| 35 | + |
| 36 | + # Close 4 tabs |
| 37 | + for i in range(4): |
| 38 | + driver.close() |
| 39 | + driver.switch_to.window(driver.window_handles[-1]) |
| 40 | + assert len(driver.window_handles) == 1 |
| 41 | + |
| 42 | + # Action Sequence hold CTRL/CMD + SHIFT and press “t” 4 times |
| 43 | + with driver.context(driver.CONTEXT_CHROME): |
| 44 | + actions = tabs.actions |
| 45 | + if sys_platform == "Darwin": |
| 46 | + actions.key_down(Keys.COMMAND).key_down(Keys.SHIFT).perform() |
| 47 | + else: |
| 48 | + actions.key_down(Keys.CONTROL).key_down(Keys.SHIFT).perform() |
| 49 | + |
| 50 | + for _ in range(4): |
| 51 | + tabs.actions.send_keys("t").perform() |
| 52 | + |
| 53 | + if sys_platform == "Darwin": |
| 54 | + tabs.actions.key_up(Keys.SHIFT).key_up(Keys.COMMAND).perform() |
| 55 | + else: |
| 56 | + tabs.actions.key_up(Keys.SHIFT).key_up(Keys.CONTROL).perform() |
| 57 | + |
| 58 | + # Verify the correct tabs reopened (order is not considered) |
| 59 | + open_urls = set() |
| 60 | + |
| 61 | + for handle in driver.window_handles: |
| 62 | + driver.switch_to.window(handle) |
| 63 | + open_urls.add(driver.current_url) |
| 64 | + |
| 65 | + for url in URLS: |
| 66 | + assert url in open_urls, f"Expected reopened tab with URL '{url}' not found" |
0 commit comments