robotframework-browser-tray 1.4.0__tar.gz → 1.5.1__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.
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/PKG-INFO +6 -14
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/README.md +5 -13
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/pyproject.toml +16 -5
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/Repl/__init__.py +5 -5
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/Repl/repl.py +9 -3
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/tray.py +27 -12
- robotframework_browser_tray-1.4.0/src/BrowserTray/Repl/jsextension.js +0 -18
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/Repl/__main__.py +0 -0
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/__init__.py +0 -0
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/__main__.py +0 -0
- {robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/chromium.png +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: robotframework-browser-tray
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.1
|
|
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
|
|
@@ -64,26 +64,18 @@ To start it execute:
|
|
|
64
64
|
ibrowser
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
On start up it
|
|
67
|
+
On start up it connects to a running Chromium (started using the tray icon) or Microsoft Edge (see below for instructions).
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
The role of an element can be easily obtained from the Accessibility Tree. To open the tree follow these steps:
|
|
72
|
-
|
|
73
|
-
1. Press F12 to open the DevTools
|
|
74
|
-
2. Select the Elements tab
|
|
75
|
-
3. In the right panel click on the Accessibility tab
|
|
76
|
-
4. In the section "Accessibility Tree" check "Enable full-page accessibility tree"
|
|
77
|
-
5. Click the button "Reload DevTools"
|
|
78
|
-
6. In the left panel click on the person icon to toggle the Accessibility Tree view
|
|
69
|
+
If you start a new browser while ibrowser is running, call the keyword "Connect" to connect ibrowser to it.
|
|
79
70
|
|
|
71
|
+
To exit ibrowser press `Ctrl-D`.
|
|
80
72
|
|
|
81
73
|
### Usage in a Robot Framework Test Suite
|
|
82
74
|
|
|
83
75
|
Add these lines to the Settings section of the .robot file:
|
|
84
76
|
|
|
85
77
|
```robotframework
|
|
86
|
-
Library Browser playwright_process_port=
|
|
78
|
+
Library Browser playwright_process_port=4711
|
|
87
79
|
Test Setup Connect To Browser http://localhost:1234 chromium use_cdp=True
|
|
88
80
|
```
|
|
89
81
|
|
|
@@ -113,7 +105,7 @@ If Microsoft Edge is installed on your machine:
|
|
|
113
105
|
|
|
114
106
|
On start up `browser-tray` checks whether `rfbrowser init` has been executed.
|
|
115
107
|
|
|
116
|
-
If this requirement is met the Playwright wrapper is started with `node site-packages/Browser/wrapper/index.js
|
|
108
|
+
If this requirement is met the Playwright wrapper is started with `node site-packages/Browser/wrapper/index.js 4711`.
|
|
117
109
|
|
|
118
110
|
Selecting "Open Chromium" in the tray icon executes `site-packages/Browser/wrapper/node_modules/playwright-core/.local-browsers/chromium-XX/chrome-win/chrome.exe --remote-debugging-port=1234 --test-type`.
|
|
119
111
|
|
|
@@ -52,26 +52,18 @@ To start it execute:
|
|
|
52
52
|
ibrowser
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
On start up it
|
|
55
|
+
On start up it connects to a running Chromium (started using the tray icon) or Microsoft Edge (see below for instructions).
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
The role of an element can be easily obtained from the Accessibility Tree. To open the tree follow these steps:
|
|
60
|
-
|
|
61
|
-
1. Press F12 to open the DevTools
|
|
62
|
-
2. Select the Elements tab
|
|
63
|
-
3. In the right panel click on the Accessibility tab
|
|
64
|
-
4. In the section "Accessibility Tree" check "Enable full-page accessibility tree"
|
|
65
|
-
5. Click the button "Reload DevTools"
|
|
66
|
-
6. In the left panel click on the person icon to toggle the Accessibility Tree view
|
|
57
|
+
If you start a new browser while ibrowser is running, call the keyword "Connect" to connect ibrowser to it.
|
|
67
58
|
|
|
59
|
+
To exit ibrowser press `Ctrl-D`.
|
|
68
60
|
|
|
69
61
|
### Usage in a Robot Framework Test Suite
|
|
70
62
|
|
|
71
63
|
Add these lines to the Settings section of the .robot file:
|
|
72
64
|
|
|
73
65
|
```robotframework
|
|
74
|
-
Library Browser playwright_process_port=
|
|
66
|
+
Library Browser playwright_process_port=4711
|
|
75
67
|
Test Setup Connect To Browser http://localhost:1234 chromium use_cdp=True
|
|
76
68
|
```
|
|
77
69
|
|
|
@@ -101,7 +93,7 @@ If Microsoft Edge is installed on your machine:
|
|
|
101
93
|
|
|
102
94
|
On start up `browser-tray` checks whether `rfbrowser init` has been executed.
|
|
103
95
|
|
|
104
|
-
If this requirement is met the Playwright wrapper is started with `node site-packages/Browser/wrapper/index.js
|
|
96
|
+
If this requirement is met the Playwright wrapper is started with `node site-packages/Browser/wrapper/index.js 4711`.
|
|
105
97
|
|
|
106
98
|
Selecting "Open Chromium" in the tray icon executes `site-packages/Browser/wrapper/node_modules/playwright-core/.local-browsers/chromium-XX/chrome-win/chrome.exe --remote-debugging-port=1234 --test-type`.
|
|
107
99
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "robotframework-browser-tray"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.5.1"
|
|
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"},
|
|
@@ -19,6 +19,21 @@ license = {text = "Apache 2.0"}
|
|
|
19
19
|
[tool.flit.module]
|
|
20
20
|
name = "BrowserTray"
|
|
21
21
|
|
|
22
|
+
|
|
23
|
+
[tool.pdm]
|
|
24
|
+
distribution = true
|
|
25
|
+
|
|
26
|
+
[tool.pdm.dev-dependencies]
|
|
27
|
+
dev = [
|
|
28
|
+
"tox>=4.15.1",
|
|
29
|
+
"pytest>=8.2.2",
|
|
30
|
+
"mypy>=1.10.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[tool.pdm.scripts]
|
|
34
|
+
test = "tox -p all"
|
|
35
|
+
|
|
36
|
+
|
|
22
37
|
[project.scripts]
|
|
23
38
|
browser-tray = "BrowserTray.tray:run"
|
|
24
39
|
ibrowser = "BrowserTray.Repl.repl:run"
|
|
@@ -26,7 +41,3 @@ ibrowser = "BrowserTray.Repl.repl:run"
|
|
|
26
41
|
[build-system]
|
|
27
42
|
requires = ["flit_core>=3.2,<4"]
|
|
28
43
|
build-backend = "flit_core.buildapi"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
[tool.pdm]
|
|
32
|
-
distribution = true
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import pathlib
|
|
2
|
-
|
|
3
1
|
from RobotDebug.RobotDebug import RobotDebug
|
|
4
2
|
from robot.libraries.BuiltIn import BuiltIn
|
|
5
3
|
|
|
6
4
|
|
|
7
5
|
class Repl(RobotDebug):
|
|
8
|
-
def __init__(self,
|
|
6
|
+
def __init__(self, **kwargs):
|
|
9
7
|
super().__init__(**kwargs)
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
self.
|
|
9
|
+
self.Library("Browser", "enable_presenter_mode=True", "playwright_process_port=4711")
|
|
10
|
+
self.connect()
|
|
11
|
+
|
|
12
|
+
def connect(self):
|
|
13
13
|
BuiltIn().run_keyword("Connect To Browser", "http://localhost:1234", "chromium", "use_cdp=True")
|
{robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/Repl/repl.py
RENAMED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import http
|
|
2
|
+
import socket
|
|
2
3
|
import sys
|
|
3
4
|
import tempfile
|
|
4
5
|
from pathlib import Path
|
|
6
|
+
import time
|
|
5
7
|
|
|
6
8
|
from robot import run_cli
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
TEST_SUITE = b"""
|
|
10
12
|
*** Settings ***
|
|
11
|
-
Library BrowserTray.Repl
|
|
13
|
+
Library BrowserTray.Repl repl=${True}
|
|
12
14
|
|
|
13
15
|
*** Test Cases ***
|
|
14
16
|
Robot Framework Debug REPL
|
|
@@ -56,12 +58,16 @@ def shell():
|
|
|
56
58
|
file_path.unlink()
|
|
57
59
|
|
|
58
60
|
|
|
59
|
-
def run():
|
|
61
|
+
def run(timeout=0):
|
|
60
62
|
try:
|
|
61
63
|
http.client.HTTPConnection('127.0.0.1', 1234, timeout=1).connect()
|
|
64
|
+
if timeout:
|
|
65
|
+
time.sleep(timeout)
|
|
66
|
+
sys.exit(0)
|
|
62
67
|
shell()
|
|
63
|
-
except
|
|
68
|
+
except socket.timeout:
|
|
64
69
|
print("ibrowser needs either:\n" +
|
|
65
70
|
" - a running Chromium, started using the tray icon or\n" +
|
|
66
71
|
" - a running Microsoft Edge started as explained in the documentation: https://pypi.org/project/robotframework-browser-tray/"
|
|
67
72
|
)
|
|
73
|
+
sys.exit(1)
|
{robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/tray.py
RENAMED
|
@@ -3,15 +3,21 @@ import os
|
|
|
3
3
|
import site
|
|
4
4
|
import subprocess
|
|
5
5
|
import sys
|
|
6
|
+
import time
|
|
6
7
|
from os.path import realpath
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
from subprocess import Popen
|
|
9
10
|
from tkinter import messagebox
|
|
11
|
+
from typing import List, Tuple
|
|
10
12
|
|
|
11
13
|
from PIL import Image
|
|
12
14
|
from pystray import Icon, Menu, MenuItem
|
|
13
15
|
|
|
14
16
|
|
|
17
|
+
REMOTE_DEBUGGING_PORT = 1234
|
|
18
|
+
PLAYWRIGHT_PROCESS_PORT= 4711
|
|
19
|
+
|
|
20
|
+
|
|
15
21
|
_, site_packages = site.getsitepackages()
|
|
16
22
|
browser_wrapper = Path(site_packages) / "Browser" / "wrapper"
|
|
17
23
|
index_js = browser_wrapper / "index.js"
|
|
@@ -19,7 +25,7 @@ node_modules = browser_wrapper / "node_modules"
|
|
|
19
25
|
playwright_core = node_modules / "playwright-core"
|
|
20
26
|
|
|
21
27
|
|
|
22
|
-
def find_chromium(path: Path) ->
|
|
28
|
+
def find_chromium(path: Path) -> List[Path]:
|
|
23
29
|
return [
|
|
24
30
|
Path(file.path)
|
|
25
31
|
for file in os.scandir(path)
|
|
@@ -40,15 +46,27 @@ def get_chromium_dir(node_modules: Path):
|
|
|
40
46
|
return find_chromium(local_browsers)[0]
|
|
41
47
|
|
|
42
48
|
|
|
43
|
-
def start_playwright(
|
|
49
|
+
def start_playwright(playwright_process_port: int) -> Popen:
|
|
44
50
|
return Popen(['node', index_js, str(playwright_process_port)])
|
|
45
51
|
|
|
46
52
|
|
|
47
|
-
|
|
48
53
|
class TrayIcon:
|
|
49
|
-
def __init__(self,
|
|
54
|
+
def __init__(self, playwright_process_port: int, remote_debugging_port: int, timeout=0):
|
|
50
55
|
chromium_icon = Image.open(Path(realpath(__file__)).parent / "chromium.png")
|
|
51
|
-
|
|
56
|
+
|
|
57
|
+
playwright_process = start_playwright(playwright_process_port)
|
|
58
|
+
time.sleep(2)
|
|
59
|
+
return_code = playwright_process.poll()
|
|
60
|
+
|
|
61
|
+
if return_code:
|
|
62
|
+
sys.exit(return_code)
|
|
63
|
+
|
|
64
|
+
if timeout:
|
|
65
|
+
time.sleep(timeout)
|
|
66
|
+
playwright_process.kill()
|
|
67
|
+
sys.exit(0)
|
|
68
|
+
|
|
69
|
+
self.processes = [playwright_process]
|
|
52
70
|
self.remote_debugging_port = remote_debugging_port
|
|
53
71
|
self.icon = Icon(
|
|
54
72
|
name='Browser Tray',
|
|
@@ -58,7 +76,7 @@ class TrayIcon:
|
|
|
58
76
|
'Open Chromium',
|
|
59
77
|
self.open_chromium,
|
|
60
78
|
default=True
|
|
61
|
-
),
|
|
79
|
+
),
|
|
62
80
|
MenuItem(
|
|
63
81
|
'Open Chromium Incognito',
|
|
64
82
|
self.open_chromium_incognito,
|
|
@@ -94,6 +112,7 @@ class TrayIcon:
|
|
|
94
112
|
incognito_flag = ["-incognito"] if incognito else []
|
|
95
113
|
chrome_exe = chromium_dir / "chrome-win" / "chrome.exe"
|
|
96
114
|
chromium = Popen([chrome_exe, f"--remote-debugging-port={remote_debugging_port}", "--test-type"] + incognito_flag)
|
|
115
|
+
time.sleep(2)
|
|
97
116
|
self.processes.append(chromium)
|
|
98
117
|
|
|
99
118
|
|
|
@@ -110,10 +129,8 @@ def is_running(cmd: str) -> bool:
|
|
|
110
129
|
return len(instances) > 1
|
|
111
130
|
|
|
112
131
|
|
|
113
|
-
def get_ports() ->
|
|
132
|
+
def get_ports() -> Tuple[int, int]:
|
|
114
133
|
MAX_PORT = 2**16
|
|
115
|
-
REMOTE_DEBUGGING_PORT = 1234
|
|
116
|
-
PLAYWRIGHT_PROCESS_PORT= 55555
|
|
117
134
|
|
|
118
135
|
arg_parser = argparse.ArgumentParser(add_help=True)
|
|
119
136
|
arg_parser.add_argument("--pw-port", default=PLAYWRIGHT_PROCESS_PORT, type=int, help=f"Playwright process port (default: {PLAYWRIGHT_PROCESS_PORT})")
|
|
@@ -144,7 +161,5 @@ def run():
|
|
|
144
161
|
)
|
|
145
162
|
sys.exit(1)
|
|
146
163
|
|
|
147
|
-
|
|
148
|
-
processes = [playwright_process]
|
|
149
|
-
tray_icon = TrayIcon(processes, remote_debugging_port)
|
|
164
|
+
tray_icon = TrayIcon(playwright_process_port, remote_debugging_port)
|
|
150
165
|
tray_icon.run()
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
async function registerMySelector(playwright) {
|
|
2
|
-
playwright.selectors.register("role", () => ({
|
|
3
|
-
// Returns the first element matching given selector in the root's subtree.
|
|
4
|
-
query(root, selector) {
|
|
5
|
-
return root.querySelector([role="${selector}"]);
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
// Returns all elements matching given selector in the root's subtree.
|
|
9
|
-
queryAll(root, selector) {
|
|
10
|
-
return Array.from(root.querySelectorAll([role="${selector}"]));
|
|
11
|
-
}
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
return 1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.registerMySelector = registerMySelector;
|
|
File without changes
|
{robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/__init__.py
RENAMED
|
File without changes
|
{robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/__main__.py
RENAMED
|
File without changes
|
{robotframework_browser_tray-1.4.0 → robotframework_browser_tray-1.5.1}/src/BrowserTray/chromium.png
RENAMED
|
File without changes
|