#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright 2019 Univention GmbH
#
# Modified by ITIS to match V18 
# https://www.univention.de/
#
# All rights reserved.
#
# The source code of this program is made available
# under the terms of the GNU Affero General Public License version 3
# (GNU AGPL V3) as published by the Free Software Foundation.
#
# Binary versions of this program provided by Univention to you as
# well as other copyrighted, protected or trademarked materials like
# Logos, graphics, fonts, specific documentations and configurations,
# cryptographic keys etc. are subject to a license agreement between
# you and Univention and not subject to the GNU AGPL V3.
#
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <https://www.gnu.org/licenses/>.
#

import os
import os.path
import importlib
import time
import sys
import random
import string
import pathlib
import zipfile

test_lib = os.environ.get('UCS_TEST_LIB', 'univention.testing.apptest')
try:
	test_lib = importlib.import_module(test_lib)
except ImportError:
	print('Could not import {}. Maybe set $UCS_TEST_LIB'.format(test_lib))
	sys.exit(1)



def _login(chrome, user):
	chrome.enter_input('login', user.properties['username'])
	chrome.enter_input('password', 'univention')
	chrome.click_element('button.btn')
	time.sleep(2)

def test_itiseasybusiness(chrome, users):
	with chrome.capture('itis_easybusiness'):
		user = users('itiseasybusiness', {'itiseasybusinessActivated': True})
		chrome.goto_portal()
		chrome.click_portal_tile(u'ITISeasy.business')
		time.sleep(4)
		chrome.driver.find_element_by_xpath("//a[@href ='/web?db=ITISeasybusiness_LIVE']").click()
		time.sleep(4)
		_login(chrome, user)
		chrome.click_element('.full')

if __name__ == '__main__':
	test_lib.run_test_file(__file__)