mirror of https://github.com/jumpserver/jumpserver
Merge pull request #9424 from jumpserver/pr@dev@perf_chrome
perf: use Chromium browserpull/9436/head
commit
431725b315
|
@ -7,6 +7,7 @@ from selenium.webdriver.chrome.service import Service
|
|||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
|
||||
from code_dialog import CodeDialog
|
||||
from common import (Asset, User, Account, Platform, Step)
|
||||
from common import (BaseApplication)
|
||||
from common import (notify_err_message, block_input, unblock_input)
|
||||
|
@ -16,6 +17,7 @@ class Command(Enum):
|
|||
TYPE = 'type'
|
||||
CLICK = 'click'
|
||||
OPEN = 'open'
|
||||
CODE = 'code'
|
||||
|
||||
|
||||
def _execute_type(ele: WebElement, value: str):
|
||||
|
@ -62,6 +64,11 @@ class StepAction:
|
|||
ele.click()
|
||||
elif self.command in ['open']:
|
||||
driver.get(self.value)
|
||||
elif self.command == 'code':
|
||||
unblock_input()
|
||||
code_string = CodeDialog(title="Code Dialog", label="Code").wait_string()
|
||||
block_input()
|
||||
ele.send_keys(code_string)
|
||||
return True
|
||||
|
||||
def _execute_command_type(self, ele, value):
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
import tkinter as tk
|
||||
from tkinter import StringVar, messagebox
|
||||
from tkinter import ttk
|
||||
|
||||
|
||||
class CodeDialog(object):
|
||||
|
||||
def __init__(self, title=None, label="Code Dialog"):
|
||||
self.root = tk.Tk()
|
||||
self.root.title(title)
|
||||
self.code = StringVar()
|
||||
mainframe = ttk.Frame(self.root, padding="12 12 12 12")
|
||||
mainframe.grid(column=0, row=0, )
|
||||
self.label = ttk.Label(mainframe, text=label, width=10)
|
||||
self.input = ttk.Entry(mainframe, textvariable=self.code, width=20)
|
||||
self.button = ttk.Button(mainframe, text="ok", command=self.click_ok, width=5,)
|
||||
self.label.grid(row=1, column=0)
|
||||
self.input.grid(row=1, column=1)
|
||||
self.button.grid(row=2, column=1, sticky=tk.E)
|
||||
self.root.bind('<Return>', self.click_ok)
|
||||
|
||||
def wait_string(self):
|
||||
# 局中
|
||||
self.root.eval('tk::PlaceWindow . center')
|
||||
self.root.mainloop()
|
||||
return self.code.get()
|
||||
|
||||
def click_ok(self, *args, **kwargs):
|
||||
if not self.code.get():
|
||||
messagebox.showwarning(title="warning", message="code is empty")
|
||||
return
|
||||
self.root.destroy()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
code = CodeDialog(title="Code Dialog", label="Code: ").wait_string()
|
||||
print(code)
|
|
@ -125,33 +125,40 @@
|
|||
pip install -r '{{ ansible_env.TEMP }}\pip_packages\requirements.txt'
|
||||
--no-index --find-links='{{ ansible_env.TEMP }}\pip_packages'
|
||||
|
||||
- name: Download chromedriver (chrome)
|
||||
- name: Download chromedriver (Chromium)
|
||||
ansible.windows.win_get_url:
|
||||
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/chromedriver_win32.zip"
|
||||
dest: "{{ ansible_env.TEMP }}\\chromedriver_win32.zip"
|
||||
|
||||
- name: Unzip chromedriver (chrome)
|
||||
- name: Unzip chromedriver (Chromium)
|
||||
community.windows.win_unzip:
|
||||
src: "{{ ansible_env.TEMP }}\\chromedriver_win32.zip"
|
||||
dest: C:\Program Files\JumpServer\drivers
|
||||
|
||||
- name: Set chromedriver on the global system path (chrome)
|
||||
- name: Download chromium zip package (Chromium)
|
||||
ansible.windows.win_get_url:
|
||||
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/chrome-win.zip"
|
||||
dest: "{{ ansible_env.TEMP }}\\chrome-win.zip"
|
||||
|
||||
- name: Unzip Chromium (Chromium)
|
||||
community.windows.win_unzip:
|
||||
src: "{{ ansible_env.TEMP }}\\chrome-win.zip"
|
||||
dest: C:\Program Files\Chrome
|
||||
|
||||
- name: Set chromium and driver on the global system path (Chromium)
|
||||
ansible.windows.win_path:
|
||||
elements:
|
||||
- 'C:\Program Files\JumpServer\drivers'
|
||||
- 'C:\Program Files\Chrome\chrome-win'
|
||||
- 'C:\Program Files\JumpServer\drivers\chromedriver_win32'
|
||||
|
||||
- name: Download chrome msi package (chrome)
|
||||
ansible.windows.win_get_url:
|
||||
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/googlechromestandaloneenterprise64.msi"
|
||||
dest: "{{ ansible_env.TEMP }}\\googlechromestandaloneenterprise64.msi"
|
||||
- name: Set Chromium variables diable Google Api (Chromium)
|
||||
ansible.windows.win_environment:
|
||||
level: machine
|
||||
variables:
|
||||
GOOGLE_API_KEY: ''
|
||||
GOOGLE_DEFAULT_CLIENT_ID: ''
|
||||
GOOGLE_DEFAULT_CLIENT_SECRET: ''
|
||||
|
||||
- name: Install chrome (chrome)
|
||||
ansible.windows.win_package:
|
||||
path: "{{ ansible_env.TEMP }}\\googlechromestandaloneenterprise64.msi"
|
||||
state: present
|
||||
arguments:
|
||||
- /quiet
|
||||
-
|
||||
- name: Download navicat161_premium_en package (navicat)
|
||||
ansible.windows.win_get_url:
|
||||
url: "{{ APPLET_DOWNLOAD_HOST }}/download/applets/navicat161_premium_en_x64.exe"
|
||||
|
|
Loading…
Reference in New Issue