mirror of https://github.com/nicolargo/glances.git
Switch to Chrome for Selenium
This commit is contained in:
parent
bce9fe3621
commit
3ec94d32f0
|
|
@ -68,8 +68,8 @@
|
|||
<div class="col-3" :class="{ 'sidebar-min': !args.percpu, 'sidebar-max': args.percpu }"
|
||||
v-if="!args.disable_left_sidebar">
|
||||
<template v-for="plugin in leftMenu">
|
||||
<component v-if="!args[`disable_${plugin}`]" :is="`glances-plugin-${plugin}`"
|
||||
:id="`plugin-${plugin}`" :data="data">
|
||||
<component v-if="!args[`disable_${plugin}`]" :is="`glances-plugin-${plugin}`" :id="`${plugin}`"
|
||||
:data="data">
|
||||
</component>
|
||||
</template>
|
||||
</div>
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -7,7 +7,13 @@
|
|||
# SPDX-License-Identifier: LGPL-3.0-only
|
||||
#
|
||||
|
||||
"""Glances unitary tests suite for the WebUI."""
|
||||
"""Glances unitary tests suite for the WebUI.
|
||||
|
||||
Need chromedriver command line (example on Ubuntu system):
|
||||
$ sudo apt install chromium-chromedriver
|
||||
|
||||
The chromedriver command line should be in your path (/usr/bin)
|
||||
"""
|
||||
|
||||
import os
|
||||
import shlex
|
||||
|
|
@ -16,8 +22,8 @@ import time
|
|||
|
||||
import pytest
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver import FirefoxOptions
|
||||
from selenium.webdriver.firefox.service import Service as FirefoxService
|
||||
from selenium.webdriver import ChromeOptions
|
||||
from selenium.webdriver.chrome.service import Service as ChromeService
|
||||
|
||||
SERVER_PORT = 61234
|
||||
URL = f"http://localhost:{SERVER_PORT}"
|
||||
|
|
@ -41,10 +47,11 @@ def glances_webserver():
|
|||
@pytest.fixture(scope="session")
|
||||
def firefox_browser():
|
||||
"""Init Firefox browser."""
|
||||
opts = FirefoxOptions()
|
||||
opts.add_argument("--headless")
|
||||
srv = FirefoxService(executable_path="/snap/bin/geckodriver")
|
||||
driver = webdriver.Firefox(options=opts, service=srv)
|
||||
opt = ChromeOptions()
|
||||
opt.add_argument("--headless")
|
||||
opt.add_argument("--start-maximized")
|
||||
srv = ChromeService()
|
||||
driver = webdriver.Chrome(options=opt, service=srv)
|
||||
|
||||
# Yield the WebDriver instance
|
||||
driver.implicitly_wait(10)
|
||||
|
|
|
|||
|
|
@ -9,11 +9,47 @@
|
|||
|
||||
"""Glances unitary tests suite for the WebUI."""
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
def test_title(glances_webserver, firefox_browser):
|
||||
import pytest
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def glances_homepage(firefox_browser):
|
||||
firefox_browser.get("http://localhost:61234")
|
||||
firefox_browser.save_screenshot(os.path.join(tempfile.gettempdir(), "glances.png"))
|
||||
return firefox_browser
|
||||
|
||||
|
||||
def test_title(glances_webserver, glances_homepage):
|
||||
"""
|
||||
Test the title of the Glances home page
|
||||
Test Glances home page title.
|
||||
"""
|
||||
assert glances_webserver is not None
|
||||
firefox_browser.get("http://localhost:61234")
|
||||
assert "Glances" in firefox_browser.title
|
||||
assert "Glances" in glances_homepage.title
|
||||
|
||||
|
||||
def test_plugins(glances_webserver, glances_homepage):
|
||||
"""
|
||||
Test Glances defaults plugins.
|
||||
"""
|
||||
assert glances_webserver is not None
|
||||
for plugin in [
|
||||
"system",
|
||||
"now",
|
||||
"uptime",
|
||||
"quicklook",
|
||||
"cpu",
|
||||
"mem",
|
||||
"memswap",
|
||||
"load",
|
||||
"network",
|
||||
"diskio",
|
||||
"fs",
|
||||
"sensors",
|
||||
"processcount",
|
||||
"processlist",
|
||||
]:
|
||||
assert glances_homepage.find_element(By.ID, plugin) is not None
|
||||
|
|
|
|||
Loading…
Reference in New Issue