-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dou Du
committed
May 30, 2024
1 parent
9cee9bc
commit ac17d7a
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated by Selenium IDE | ||
import pytest | ||
import time | ||
import json | ||
import os | ||
from selenium import webdriver | ||
from selenium.webdriver.chrome.options import Options | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.common.action_chains import ActionChains | ||
from selenium.webdriver.support import expected_conditions | ||
from selenium.webdriver.support.wait import WebDriverWait | ||
from selenium.webdriver.common.keys import Keys | ||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | ||
|
||
class test_widget(): | ||
def setup_method(self, method): | ||
options = Options() | ||
cwd = os.getcwd() | ||
options.add_experimental_option("prefs", {"download.default_directory": cwd}) | ||
self.driver = webdriver.Chrome(options=options) | ||
self.vars = {} | ||
|
||
def teardown_method(self, method): | ||
self.driver.quit() | ||
|
||
def download_widget_image(self): | ||
self.driver.get("http://localhost:8383/voila/render/example.ipynb") | ||
self.driver.set_window_size(1280, 720) | ||
time.sleep(3) | ||
self.driver.save_screenshot("widget-01.png") | ||
self.driver.execute_script("window.scrollTo(0, 1000)") | ||
time.sleep(3) | ||
self.driver.save_screenshot("widget-02.png") | ||
|
||
test = test_widget() | ||
test.setup_method('Chrome') | ||
test.download_widget_image() | ||
test.teardown_method('Chrome') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from PIL import Image, ImageChops, ImageStat | ||
|
||
image1 = Image.open('widget-01.png') | ||
image2 = Image.open('test/widget-sample.png') | ||
|
||
diff = ImageChops.difference(image1, image2) | ||
stat = ImageStat.Stat(diff) | ||
|
||
if sum(stat.mean) == 0: | ||
print('images are the same') | ||
else: | ||
raise Exception("The result is NOT the same as expected. Please check matplotlib version.") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.