Merge "gitea: add some screenshots to testing"
This commit is contained in:
commit
7a90a92ebb
@ -1,5 +1,9 @@
|
|||||||
- hosts: "gitea"
|
- hosts: "gitea"
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Run selenium container
|
||||||
|
include_role:
|
||||||
|
name: run-selenium
|
||||||
|
|
||||||
- name: Test base jobs project was created in gitea
|
- name: Test base jobs project was created in gitea
|
||||||
uri:
|
uri:
|
||||||
url: "https://localhost:3000/opendev/base-jobs"
|
url: "https://localhost:3000/opendev/base-jobs"
|
||||||
|
@ -12,6 +12,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
|
|
||||||
testinfra_hosts = ['gitea99.opendev.org']
|
testinfra_hosts = ['gitea99.opendev.org']
|
||||||
|
|
||||||
@ -84,3 +89,48 @@ def test_project_clone(host):
|
|||||||
'/tmp/disk-image-builder')
|
'/tmp/disk-image-builder')
|
||||||
assert "Cloning into '/tmp/disk-image-builder'..." in cmd.stderr
|
assert "Cloning into '/tmp/disk-image-builder'..." in cmd.stderr
|
||||||
assert cmd.succeeded
|
assert cmd.succeeded
|
||||||
|
|
||||||
|
def test_gitea_screenshots(host):
|
||||||
|
driver = webdriver.Remote(
|
||||||
|
command_executor='http://%s:4444/wd/hub' % (host.backend.get_hostname()),
|
||||||
|
desired_capabilities=webdriver.DesiredCapabilities.FIREFOX)
|
||||||
|
|
||||||
|
shots = (
|
||||||
|
('https://localhost:3081', 'gitea-main.png'),
|
||||||
|
('https://localhost:3081/opendev/system-config',
|
||||||
|
'gitea-project-system-config.png'),
|
||||||
|
('https://localhost:3081/opendev/disk-image-builder',
|
||||||
|
'gitea-project-dib.png')
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
for url, png in shots:
|
||||||
|
driver.get(url)
|
||||||
|
WebDriverWait(driver, 30).until(
|
||||||
|
lambda driver: driver.execute_script(
|
||||||
|
'return document.readyState') == 'complete')
|
||||||
|
time.sleep(5)
|
||||||
|
# NOTE(ianw) This is a mash-up of things I found on
|
||||||
|
# stackoverflow and other bits googling "full size
|
||||||
|
# screenshot". You expand the viewport and take a
|
||||||
|
# shot of the <body> element so that you don't also
|
||||||
|
# get scrollbars in the shot, with some tweaking
|
||||||
|
# because the window size. Apparently selinum 4
|
||||||
|
# will have getFullPageScreeshotAs, so we should switch
|
||||||
|
# to that when available.
|
||||||
|
original_size = driver.get_window_size()
|
||||||
|
required_width = driver.execute_script(
|
||||||
|
'return document.body.parentNode.scrollWidth')
|
||||||
|
required_height = driver.execute_script(
|
||||||
|
'return document.body.parentNode.scrollHeight') + 100
|
||||||
|
driver.set_window_size(required_width, required_height)
|
||||||
|
|
||||||
|
driver.find_element_by_tag_name('body'). \
|
||||||
|
screenshot("/var/log/screenshots/%s" % png)
|
||||||
|
|
||||||
|
driver.set_window_size(
|
||||||
|
original_size['width'], original_size['height'])
|
||||||
|
|
||||||
|
except TimeoutException as e:
|
||||||
|
raise e
|
||||||
|
finally:
|
||||||
|
driver.quit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user