Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions l10n_CM/run_l10n.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@
"zalando",
"zara",
"zooplus",
"zara",
"cocolita",
"torfs",
"standaardboekhandel",
"douglas",
"brico",
"toychamp",
}

loaded_valid_sites = valid_l10n_mappings().keys()
Expand Down
11 changes: 9 additions & 2 deletions modules/browser_object_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,17 @@ def open_bookmark_in_new_tab_via_context_menu(
Argument:
bookmark_title: The title of the bookmark to open
"""
# Right-click the bookmark and open it in new tabe via context menu item
# Right-click the bookmark to make the menu appear
self.panel_ui.element_clickable("bookmark-by-title", labels=[bookmark_title])
self.panel_ui.context_click("bookmark-by-title", labels=[bookmark_title])
self.context_menu.click_on("context-menu-toolbar-open-in-new-tab")

# Find the menu item we want to click
# We use .fetch() here to get the element without clicking it yet
menu_item = self.context_menu.fetch("context-menu-toolbar-open-in-new-tab")

# Use ActionChains to perform a more reliable click
actions = ActionChains(self.driver)
actions.move_to_element(menu_item).click().perform()

return self

Expand Down
16 changes: 16 additions & 0 deletions modules/page_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,22 @@ def get_element(
cache_name = f"{name}{labelscode}"
if cache_name not in self.elements:
self.elements[cache_name] = deepcopy(self.elements[name])
# FIX: Check for doNotCache BEFORE trying to use cached elements
if (
not multiple
and "doNotCache"
not in self.elements[cache_name]["groups"] # ADD THIS CHECK
and "seleniumObject" in self.elements[cache_name]
):
# no caching for multiples
cached_element = self.elements[cache_name]["seleniumObject"]
try:
self.instawait.until_not(EC.staleness_of(cached_element))
logging.info(f"Returned {cache_name} from object cache!")
return self.elements[cache_name]["seleniumObject"]
except (TimeoutError, TimeoutException):
# Because we have a timeout of 0, this should not cause delays
pass
if multiple:
logging.info(f"Multiples: Not caching {cache_name}...")
if not multiple and "seleniumObject" in self.elements[cache_name]:
Expand Down
83 changes: 83 additions & 0 deletions tests/tabs/test_change_position_of_pinned_tabs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import logging
import time

import pytest
from selenium.webdriver import Firefox
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By

from modules.browser_object import ContextMenu, Navigation, TabBar


@pytest.fixture()
def test_case():
return "134723"


def test_change_position_of_pinned_tabs(driver: Firefox):
tabs = TabBar(driver)
nav = Navigation(driver)
tabs_context_menu = ContextMenu(driver)
num_tabs = 5

tab_titles = []
url_list = [
"https://www.google.com",
"https://www.youtube.com",
"https://www.mozilla.org",
"https://www.wikipedia.org",
"https://www.github.com",
]

driver.get(url_list[0])
tab_titles.append(driver.title)

# Open 5 tabs
for i in range(1, len(url_list)):
tabs.new_tab_by_button()
driver.switch_to.window(driver.window_handles[-1])
driver.get(url_list[i])
tab_titles.append(driver.title)
time.sleep(2)

# specific tabs we want to work with
google_title = tab_titles[0]
mozilla_title = tab_titles[2]

# Pin the 'Google' tab by its title
driver.switch_to.window(driver.window_handles[0])
google_tab = tabs.get_tab(google_title)
assert google_tab is not None, "Google tab should exist"
tabs.context_click(google_tab)
tabs_context_menu.click_context_item("context-menu-pin-tab")
time.sleep(1)

# FIX: Re-initialize the context menu object after the DOM has changed.
# FIX: Force a "context reset" by switching to a neutral tab.
driver.switch_to.window(driver.window_handles[1]) # Switch to YouTube
time.sleep(0.5) # A brief pause to ensure the context switch completes
tabs_context_menu = ContextMenu(driver)

# Pin the 'Mozilla' tab by its title
driver.switch_to.window(driver.window_handles[2])
mozilla_tab = tabs.get_tab(mozilla_title)
assert mozilla_tab is not None, "Mozilla tab should exist"
tabs.context_click(mozilla_tab)
tabs_context_menu.click_context_item("context-menu-pin-tab")
time.sleep(1)

driver.switch_to.window(driver.window_handles[0])
pinned_tab_one = tabs.get_tab(google_title)
assert tabs.is_pinned(pinned_tab_one)

# ERROR
# pinned_tab_two = tabs.get_tab(mozilla_title)
# assert tabs.is_pinned(pinned_tab_two)

# -----------------------after pinned error is fixed ------------------------------------
# actions = ActionChains(driver)
# # A more robust, manual way to perform a drag-and-drop
# actions.drag_and_drop(pinned_tab_one, pinned_tab_two).perform()

# assert tab_titles[0] in new_pinned_tab_one.text, "Google should now be the first pinned tab"
# assert tab_titles[2] in new_pinned_tab_two.text, "Mozilla should now be the second pinned tab"
Loading