robotframework-browser-tray 1.5.2__tar.gz → 1.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: robotframework-browser-tray
3
- Version: 1.5.2
3
+ Version: 1.6.0
4
4
  Summary: Tray icon and REPL for trying out Browser Library keywords using Chromium or Edge
5
5
  Author-email: Marduk Bolaños <marduk.bolanos@imbus.de>
6
6
  Requires-Python: >=3.8.2
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "robotframework-browser-tray"
3
- version = "1.5.2"
3
+ version = "1.6.0"
4
4
  description = "Tray icon and REPL for trying out Browser Library keywords using Chromium or Edge"
5
5
  authors = [
6
6
  {name = "Marduk Bolaños", email = "marduk.bolanos@imbus.de"},
@@ -31,7 +31,7 @@ dev = [
31
31
  ]
32
32
 
33
33
  [tool.pdm.scripts]
34
- test = "tox -p all"
34
+ test = "tox"
35
35
 
36
36
 
37
37
  [project.scripts]
@@ -6,7 +6,7 @@ class Repl(RobotDebug):
6
6
  def __init__(self, **kwargs):
7
7
  super().__init__(**kwargs)
8
8
 
9
- self.Library("Browser", "enable_presenter_mode=True", "playwright_process_port=4711")
9
+ self.Library("Browser", "enable_presenter_mode=True", "playwright_process_port=4711", "timeout=2s")
10
10
  self.connect()
11
11
 
12
12
  def connect(self):
@@ -1,11 +1,56 @@
1
1
  import http.client
2
+ import re
2
3
  import socket
3
4
  import sys
4
5
  import tempfile
5
- from pathlib import Path
6
6
  import time
7
+ from functools import wraps
8
+ from pathlib import Path
9
+
10
+ import RobotDebug.styles
11
+ from Browser.base.librarycomponent import LibraryComponent
12
+ from robot.run import run_cli
13
+ from robot.api import logger
14
+
15
+
16
+ def escape_ansi(line):
17
+ ansi_escape = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]')
18
+ return ansi_escape.sub('', line)
19
+
20
+
21
+ print_output = RobotDebug.styles.print_output
22
+
23
+ @wraps(print_output)
24
+ def wrap_print_output(head, message, style=RobotDebug.styles.NORMAL_STYLE):
25
+ print_output(head, escape_ansi(message), style)
26
+
27
+ RobotDebug.styles.print_output = wrap_print_output
28
+
29
+
30
+ presenter_mode = LibraryComponent.presenter_mode
31
+
32
+ @wraps(presenter_mode)
33
+ def wrap_presenter_mode(self, selector, strict):
34
+ selector = self.resolve_selector(selector)
35
+ if self.library.presenter_mode:
36
+ mode = self.get_presenter_mode
37
+ try:
38
+ self.library.scroll_to_element(selector)
39
+ self.library.highlight_elements(
40
+ selector,
41
+ duration=mode["duration"],
42
+ width=mode["width"],
43
+ style=mode["style"],
44
+ color=mode["color"],
45
+ )
46
+ except Exception as error:
47
+ # selector = self.library.record_selector(f'"{selector}" failure')
48
+ logger.debug(f"On presenter more supress {error}")
49
+ else:
50
+ time.sleep(mode["duration"].seconds)
51
+ return selector
7
52
 
8
- from robot import run_cli
53
+ LibraryComponent.presenter_mode = wrap_presenter_mode
9
54
 
10
55
 
11
56
  TEST_SUITE = b"""
@@ -6,6 +6,7 @@ import socket
6
6
  import subprocess
7
7
  import sys
8
8
  import time
9
+ import tkinter as tk
9
10
  from os.path import realpath
10
11
  from pathlib import Path
11
12
  from subprocess import Popen
@@ -109,7 +110,9 @@ class TrayIcon:
109
110
  chromium_dir = get_chromium_dir(node_modules)
110
111
 
111
112
  if not chromium_dir:
112
- messagebox.showerror("Error", "Chromium is not installed. Execute 'rfbrowser init chromium'.")
113
+ window = tk.Tk()
114
+ window.withdraw()
115
+ messagebox.showerror("Error", "Chromium is not installed. Execute 'rfbrowser init chromium'.", master=window)
113
116
  else:
114
117
  incognito_flag = ["-incognito"] if incognito else []
115
118
  chrome_exe = chromium_dir / "chrome-win" / "chrome.exe"