Răsfoiți Sursa

adding tab switching to screen
This is needed to reproduce the object duplication bug in ui.scene

Rodja Trappe 2 ani în urmă
părinte
comite
b4e60f00b4
1 a modificat fișierele cu 9 adăugiri și 0 ștergeri
  1. 9 0
      tests/screen.py

+ 9 - 0
tests/screen.py

@@ -70,6 +70,15 @@ class Screen:
         if self.is_open:
             self.selenium.close()
 
+    def switch_to(self, tab_id: int) -> None:
+        window_count = len(self.selenium.window_handles)
+        if tab_id > window_count:
+            raise IndexError(f'Could not go to or create tab {tab_id}, there are only {window_count} tabs')
+        elif tab_id == window_count:
+            self.selenium.switch_to.new_window('tab')
+        else:
+            self.selenium.switch_to.window(self.selenium.window_handles[tab_id])
+
     def should_contain(self, text: str) -> None:
         assert self.selenium.title == text or self.find(text), f'could not find "{text}"'