Skip to content
Snippets Groups Projects
Commit f86f315e authored by József Gyürüsi's avatar József Gyürüsi
Browse files

nadia fixes:


This is a big email about fixes for CLL_REGRESSION and WEBGUI_REGRESSION jobs. Regarding WebGUI the next scripts should be the same in EPTF_Web_GUI_CNL113864 and EPTF_Core_Library_CNL113512:

    runTestsWithXvfb.sh
    RequestConsole_Tests.py
    GuiEditor_EditorTests.py
    Framework_LoadingWebApps.py
    runTests.py
    GuiEditor_SetupHandlingTests.py
    GuiEditor_CommonFunctions.py
    Framework_CommonFunctions.py
    BaseTestCase.py

createOfflineWebGUI.sh differs, so I attach 2 of them.

Change-Id: I9d7e74c4a9fe8ffab0f635b2b8ad06337ef1e135
Signed-off-by: default avatarJózsef Gyürüsi <jozsef.gyurusi@ericsson.com>
parent c74863c6
No related branches found
No related tags found
No related merge requests found
...@@ -14,14 +14,16 @@ import unittest ...@@ -14,14 +14,16 @@ import unittest
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.firefox.service import Service
class BaseTestCase(unittest.TestCase): class BaseTestCase(unittest.TestCase):
# yes... a \ has to be escaped even in a raw string, and a string can not end with \, so we have to create a string that does not end with a \ and get the \ character from its index... # yes... a \ has to be escaped even in a raw string, and a string can not end with \, so we have to create a string that does not end with a \ and get the \ character from its index...
HTML_FILE = ("file:///" + os.path.abspath("../Test.html").replace(r"\\ "[0], r"/")) HTML_FILE = ("file:///" + os.path.abspath("../WebGUI/htdocs/Test.html").replace(r"\\ "[0], r"/"))
def setUp(self): def setUp(self):
self.driver = webdriver.Firefox() service = Service(executable_path="/usr/local/bin/geckodriver")
self.driver = webdriver.Firefox(service=service)
self.driver.maximize_window() self.driver.maximize_window()
self.driver.implicitly_wait(3) self.driver.implicitly_wait(3)
# these are not built in members, but no one said we could not add them # these are not built in members, but no one said we could not add them
...@@ -43,4 +45,4 @@ class BaseTestCase(unittest.TestCase): ...@@ -43,4 +45,4 @@ class BaseTestCase(unittest.TestCase):
self.driver.quit() self.driver.quit()
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(catchbreak=True, verbosity=2) unittest.main(catchbreak=True, verbosity=2)
\ No newline at end of file
...@@ -40,7 +40,7 @@ def browserCompatibilityCheck(driver): ...@@ -40,7 +40,7 @@ def browserCompatibilityCheck(driver):
driver.applicationStarted = True driver.applicationStarted = True
time.sleep(1) time.sleep(1)
try: try:
div = driver.find_element_by_id('UnsupportedBrowser').find_element_by_tag_name('button').click() div = driver.find_element(By.ID,'UnsupportedBrowser').find_element(By.TAG_NAME,'button').click()
time.sleep(1) time.sleep(1)
except NoSuchElementException as e: except NoSuchElementException as e:
pass pass
\ No newline at end of file
...@@ -43,7 +43,7 @@ class Framework_LoadingWebApps(BaseTestCase): ...@@ -43,7 +43,7 @@ class Framework_LoadingWebApps(BaseTestCase):
def checkApplicationStart(self, element_id): def checkApplicationStart(self, element_id):
try: try:
element = self.driver.find_element_by_id(element_id) element = self.driver.find_element(By.ID, element_id)
except NoSuchElementException as e: except NoSuchElementException as e:
self.fail("element by id " + element_id + " not found after starting application") self.fail("element by id " + element_id + " not found after starting application")
...@@ -66,7 +66,7 @@ class Framework_LoadingWebApps(BaseTestCase): ...@@ -66,7 +66,7 @@ class Framework_LoadingWebApps(BaseTestCase):
def checkApplicationSwitch(self, element_id1, element_id2): def checkApplicationSwitch(self, element_id1, element_id2):
try: try:
self.driver.find_element_by_id(element_id1) self.driver.find_element(By.ID, element_id1)
self.fail("element by id " + element_id + " found, but it should not exist after switching applications") self.fail("element by id " + element_id + " found, but it should not exist after switching applications")
except NoSuchElementException as e: except NoSuchElementException as e:
pass pass
...@@ -90,4 +90,4 @@ class Framework_LoadingWebApps(BaseTestCase): ...@@ -90,4 +90,4 @@ class Framework_LoadingWebApps(BaseTestCase):
self.checkApplicationSwitch("RequestConsole_MainView", "customAppMainview") self.checkApplicationSwitch("RequestConsole_MainView", "customAppMainview")
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(catchbreak=True, verbosity=2) unittest.main(catchbreak=True, verbosity=2)
\ No newline at end of file
...@@ -28,7 +28,7 @@ def loadSetup(driver, setupName): ...@@ -28,7 +28,7 @@ def loadSetup(driver, setupName):
radioId = "GuiEditor_Dialog_LoadSetup_RadioButton_" + setupName radioId = "GuiEditor_Dialog_LoadSetup_RadioButton_" + setupName
loadButton = driver.wait.until(EC.element_to_be_clickable((By.ID, 'GuiEditor_Button_Load'))) loadButton = driver.wait.until(EC.element_to_be_clickable((By.ID, 'GuiEditor_Button_Load')))
loadButton.click() loadButton.click()
radioButton = driver.find_element_by_id(radioId) radioButton = driver.find_element(By.ID, radioId)
radioButton.click() radioButton.click()
dialogClickOk(driver, "LoadSetup") dialogClickOk(driver, "LoadSetup")
time.sleep(1) time.sleep(1)
...@@ -40,17 +40,17 @@ def saveSetup(driver): ...@@ -40,17 +40,17 @@ def saveSetup(driver):
def saveSetupAs(driver, setupName, exists = False, overwrite = False): def saveSetupAs(driver, setupName, exists = False, overwrite = False):
button = driver.wait.until(EC.element_to_be_clickable((By.ID, 'GuiEditor_Button_SaveAs'))) button = driver.wait.until(EC.element_to_be_clickable((By.ID, 'GuiEditor_Button_SaveAs')))
button.click() button.click()
editBox = driver.find_element_by_id("GuiEditor_Dialog_SaveSetupAs_Field") editBox = driver.find_element(By.ID, "GuiEditor_Dialog_SaveSetupAs_Field")
ActionChains(driver).move_to_element(editBox).send_keys(Keys.HOME).perform() ActionChains(driver).move_to_element(editBox).send_keys(Keys.HOME).perform()
ActionChains(driver).key_down(Keys.SHIFT).send_keys(Keys.END).key_up(Keys.SHIFT).send_keys(Keys.DELETE).perform() ActionChains(driver).key_down(Keys.SHIFT).send_keys(Keys.END).key_up(Keys.SHIFT).send_keys(Keys.DELETE).perform()
ActionChains(driver).send_keys(setupName).perform() ActionChains(driver).send_keys(setupName).perform()
dialogClickOk(driver, "SaveSetupAs") dialogClickOk(driver, "SaveSetupAs")
try: try:
driver.find_element_by_id("GuiEditor_Dialog_OverWrite") driver.find_element(By.ID, "GuiEditor_Dialog_OverWrite")
if overwrite: if overwrite:
dialogClickOk(driver, "OverWrite") dialogClickOk(driver, "OverWrite")
else: else:
closeButton = driver.find_element_by_class_name("ui-dialog-titlebar").find_element_by_class_name("ui-dialog-titlebar-close") closeButton = driver.find_element(By.CLASS_NAME, "ui-dialog-titlebar").find_element(By.CLASS_NAME, "ui-dialog-titlebar-close")
closeButton.click() closeButton.click()
return exists return exists
except NoSuchElementException as e: except NoSuchElementException as e:
...@@ -75,14 +75,14 @@ def addEmptyRequest(driver): ...@@ -75,14 +75,14 @@ def addEmptyRequest(driver):
# ---------- Editor manipulating functions ---------- # ---------- Editor manipulating functions ----------
def rightClickLabel(driver, editorId): def rightClickLabel(driver, editorId):
element = driver.find_element_by_id(editorId + "_Header") element = driver.find_element(By.ID, editorId + "_Header")
actions = ActionChains(driver) actions = ActionChains(driver)
actions.context_click(element) actions.context_click(element)
actions.perform() actions.perform()
time.sleep(0.25) time.sleep(0.25)
def clickInContextMenu(driver, text): def clickInContextMenu(driver, text):
listElements = driver.find_elements_by_css_selector("#GuiEditor_ContextMenu > li") listElements = driver.find_element(By.CSS_SELECTOR, "#GuiEditor_ContextMenu > li")
for element in listElements: for element in listElements:
if element.text == text: if element.text == text:
element.click() element.click()
...@@ -103,12 +103,12 @@ def closeCustomDataEditor(driver): ...@@ -103,12 +103,12 @@ def closeCustomDataEditor(driver):
# ---------- Connection creation ---------- # ---------- Connection creation ----------
def getNodeFromTreeByElements(driver, treeId, elements): def getNodeFromTreeByElements(driver, treeId, elements):
children = driver.find_elements_by_css_selector("#" + treeId + " > ul > li") children = driver.find_element(By.CSS_SELECTOR, "#" + treeId + " > ul > li")
nodeToReturn = None nodeToReturn = None
for i in range(len(elements)): for i in range(len(elements)):
missing = True missing = True
for node in children: for node in children:
nodeText = node.find_element_by_class_name("jstree-anchor").text nodeText = node.find_element(By.CLASS_NAME, "jstree-anchor").text
if nodeText == elements[i]: if nodeText == elements[i]:
nodeToReturn = node nodeToReturn = node
missing = False missing = False
...@@ -116,33 +116,33 @@ def getNodeFromTreeByElements(driver, treeId, elements): ...@@ -116,33 +116,33 @@ def getNodeFromTreeByElements(driver, treeId, elements):
if missing: return None if missing: return None
if i < len(elements) - 1: if i < len(elements) - 1:
if "jstree-closed" in nodeToReturn.get_attribute("class"): if "jstree-closed" in nodeToReturn.get_attribute("class"):
nodeToReturn.find_element_by_class_name("jstree-icon").click() nodeToReturn.find_element(By.CLASS_NAME, "jstree-icon").click()
time.sleep(0.25) time.sleep(0.25)
children = nodeToReturn.find_elements_by_css_selector("ul > li") children = nodeToReturn.find_element(By.CSS_SELECTOR, "ul > li")
return nodeToReturn return nodeToReturn
def getNodeFromTreeByPath(driver, treeId, path): def getNodeFromTreeByPath(driver, treeId, path):
children = driver.find_elements_by_css_selector("#" + treeId + " > ul > li") children = driver.find_element(By.CSS_SELECTOR, "#" + treeId + " > ul > li")
nodeToReturn = None nodeToReturn = None
for i in range(len(path)): for i in range(len(path)):
if not path[i] < len(children): return None if not path[i] < len(children): return None
nodeToReturn = children[path[i]] nodeToReturn = children[path[i]]
if i < len(path) - 1: if i < len(path) - 1:
if "jstree-closed" in nodeToReturn.get_attribute("class"): if "jstree-closed" in nodeToReturn.get_attribute("class"):
nodeToReturn.find_element_by_class_name("jstree-icon").click() nodeToReturn.find_element(By.CLASS_NAME, "jstree-icon").click()
time.sleep(0.25) time.sleep(0.25)
children = nodeToReturn.find_elements_by_css_selector("ul > li") children = nodeToReturn.find_element(By.CSS_SELECTOR, "ul > li")
return nodeToReturn return nodeToReturn
def clickInTreeContextMenu(driver, node, menuText): def clickInTreeContextMenu(driver, node, menuText):
anchor = node.find_element_by_class_name("jstree-anchor") anchor = node.find_element(By.CLASS_NAME, "jstree-anchor")
actions = ActionChains(driver) actions = ActionChains(driver)
actions.context_click(anchor) actions.context_click(anchor)
actions.perform() actions.perform()
time.sleep(0.5) time.sleep(0.5)
contextMenu = driver.find_element_by_class_name("jstree-default-contextmenu") contextMenu = driver.find_element(By.CLASS_NAME, "jstree-default-contextmenu")
items = contextMenu.find_elements_by_tag_name("li") items = contextMenu.find_element(By.TAG_NAME, "li")
for element in items: for element in items:
if menuText in element.text: if menuText in element.text:
element.click() element.click()
...@@ -156,8 +156,8 @@ def pressDeleteOnNode(driver, node): ...@@ -156,8 +156,8 @@ def pressDeleteOnNode(driver, node):
time.sleep(0.25) time.sleep(0.25)
def dragAndDrop(driver, fromId, toId): def dragAndDrop(driver, fromId, toId):
source = driver.find_element_by_id(fromId) source = driver.find_element(By.ID, fromId)
target = driver.find_element_by_id(toId) target = driver.find_element(By.ID, toId)
target.location_once_scrolled_into_view target.location_once_scrolled_into_view
action_chains = ActionChains(driver) action_chains = ActionChains(driver)
...@@ -169,7 +169,7 @@ def dragAndDrop(driver, fromId, toId): ...@@ -169,7 +169,7 @@ def dragAndDrop(driver, fromId, toId):
def addEditor(driver, className, radioButtonToSelect, buttonSuffix): def addEditor(driver, className, radioButtonToSelect, buttonSuffix):
existingEditorIds = set() existingEditorIds = set()
existingEditors = driver.find_elements_by_class_name(className) existingEditors = driver.find_element(By.CLASS_NAME, className)
for editor in existingEditors: for editor in existingEditors:
editorId = editor.get_attribute("id") editorId = editor.get_attribute("id")
existingEditorIds.add(editorId) existingEditorIds.add(editorId)
...@@ -181,7 +181,7 @@ def addEditor(driver, className, radioButtonToSelect, buttonSuffix): ...@@ -181,7 +181,7 @@ def addEditor(driver, className, radioButtonToSelect, buttonSuffix):
time.sleep(0.25) time.sleep(0.25)
newEditorId = None newEditorId = None
existingEditors = driver.find_elements_by_class_name(className) existingEditors = driver.find_element(By.CLASS_NAME, className)
for editor in existingEditors: for editor in existingEditors:
editorId = editor.get_attribute("id") editorId = editor.get_attribute("id")
if editorId not in existingEditorIds: if editorId not in existingEditorIds:
...@@ -190,8 +190,8 @@ def addEditor(driver, className, radioButtonToSelect, buttonSuffix): ...@@ -190,8 +190,8 @@ def addEditor(driver, className, radioButtonToSelect, buttonSuffix):
return newEditorId return newEditorId
def selectRadioButtonInDialog(driver, dialogName, className): def selectRadioButtonInDialog(driver, dialogName, className):
dialog = driver.find_element_by_id("GuiEditor_Dialog_" + dialogName) dialog = driver.find_element(By.ID, "GuiEditor_Dialog_" + dialogName)
radio_button = dialog.find_element_by_id("GuiEditor_Dialog_" + dialogName + "_RadioButton_" + className) radio_button = dialog.find_element(By.ID, "GuiEditor_Dialog_" + dialogName + "_RadioButton_" + className)
radio_button.click() radio_button.click()
def dialogClickOk(driver, name): def dialogClickOk(driver, name):
...@@ -200,20 +200,20 @@ def dialogClickOk(driver, name): ...@@ -200,20 +200,20 @@ def dialogClickOk(driver, name):
button.click() button.click()
def getSetupName(driver): def getSetupName(driver):
label = driver.find_element_by_id("GuiEditor_SetupNameLabel") label = driver.find_element(By.ID, "GuiEditor_SetupNameLabel")
return label.text return label.text
def treeExists(driver, id): def treeExists(driver, id):
try: try:
div = driver.find_element_by_id(id) div = driver.find_element(By.ID, id)
div.find_element_by_class_name("jstree-node") div.find_element(By.CLASS_NAME, "jstree-node")
return True return True
except NoSuchElementException as e: except NoSuchElementException as e:
return False return False
def editorTypeExists(driver, className): def editorTypeExists(driver, className):
try: try:
driver.find_element_by_class_name(className) driver.find_element(By.CLASS_NAME, className)
return True return True
except NoSuchElementException as e: except NoSuchElementException as e:
return False return False
...@@ -221,7 +221,7 @@ def editorTypeExists(driver, className): ...@@ -221,7 +221,7 @@ def editorTypeExists(driver, className):
def dialogExists(driver, name): def dialogExists(driver, name):
dialogId = "GuiEditor_Dialog_" + name dialogId = "GuiEditor_Dialog_" + name
try: try:
driver.find_element_by_id(dialogId) driver.find_element(By.ID, dialogId)
return True return True
except NoSuchElementException as e: except NoSuchElementException as e:
return False return False
......
...@@ -96,7 +96,7 @@ class GuiEditor_EditorTests(BaseTestCase): ...@@ -96,7 +96,7 @@ class GuiEditor_EditorTests(BaseTestCase):
script = "a = '" + customData + "';" + "view_editor = $('#GuiEditor_CustomDataEditor .CodeMirror')[0].CodeMirror; view_editor.setValue(a);" script = "a = '" + customData + "';" + "view_editor = $('#GuiEditor_CustomDataEditor .CodeMirror')[0].CodeMirror; view_editor.setValue(a);"
self.driver.execute_script(script) self.driver.execute_script(script)
editorHeader = self.driver.find_element_by_id("GuiEditor_CustomDataEditor_Header") editorHeader = self.driver.find_element(By.ID, "GuiEditor_CustomDataEditor_Header")
editorHeaderColor = editorHeader.value_of_css_property("color") editorHeaderColor = editorHeader.value_of_css_property("color")
self.assertEqual('#ff0000', str(Color.from_string(editorHeaderColor).hex), 'Custom data editor header should be red, it is ' + editorHeaderColor) self.assertEqual('#ff0000', str(Color.from_string(editorHeaderColor).hex), 'Custom data editor header should be red, it is ' + editorHeaderColor)
...@@ -123,4 +123,4 @@ class GuiEditor_EditorTests(BaseTestCase): ...@@ -123,4 +123,4 @@ class GuiEditor_EditorTests(BaseTestCase):
self.assertFalse(editorTypeExists(self.driver, "GuiEditor_ViewEditor"), "ViewEditor element found after it was deleted") self.assertFalse(editorTypeExists(self.driver, "GuiEditor_ViewEditor"), "ViewEditor element found after it was deleted")
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(catchbreak=True, verbosity=2) unittest.main(catchbreak=True, verbosity=2)
\ No newline at end of file
...@@ -68,7 +68,7 @@ class GuiEditor_SetupHandlingTests(BaseTestCase): ...@@ -68,7 +68,7 @@ class GuiEditor_SetupHandlingTests(BaseTestCase):
self.driver.get(self.HTML_FILE) self.driver.get(self.HTML_FILE)
startGuiEditor(self.driver) startGuiEditor(self.driver)
setupName = getSetupName(self.driver) setupName = getSetupName(self.driver)
viewmodelEditor = self.driver.find_element_by_id("GuiEditor_ViewmodelEditor_0") viewmodelEditor = self.driver.find_element(By.ID, "GuiEditor_ViewmodelEditor_0")
time.sleep(0.5) time.sleep(0.5)
rightClickLabel(self.driver, "GuiEditor_ViewmodelEditor_0") rightClickLabel(self.driver, "GuiEditor_ViewmodelEditor_0")
...@@ -82,7 +82,7 @@ class GuiEditor_SetupHandlingTests(BaseTestCase): ...@@ -82,7 +82,7 @@ class GuiEditor_SetupHandlingTests(BaseTestCase):
loadSetup(self.driver, setupName) loadSetup(self.driver, setupName)
try: try:
viewmodelEditor = self.driver.find_element_by_id("GuiEditor_ViewmodelEditor_0") viewmodelEditor = self.driver.find_element(By.ID, "GuiEditor_ViewmodelEditor_0")
self.fail("Deleted ViewModel Editor is still present in the saved setup") self.fail("Deleted ViewModel Editor is still present in the saved setup")
except NoSuchElementException as e: except NoSuchElementException as e:
pass pass
...@@ -115,4 +115,4 @@ class GuiEditor_SetupHandlingTests(BaseTestCase): ...@@ -115,4 +115,4 @@ class GuiEditor_SetupHandlingTests(BaseTestCase):
self.assertTrue(saveSetupAs(self.driver, "Test2", True, False), "SaveAs overwrite checking is not ok") self.assertTrue(saveSetupAs(self.driver, "Test2", True, False), "SaveAs overwrite checking is not ok")
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(catchbreak=True, verbosity=2) unittest.main(catchbreak=True, verbosity=2)
\ No newline at end of file
...@@ -23,7 +23,7 @@ def loadSetup(driver, setupName): ...@@ -23,7 +23,7 @@ def loadSetup(driver, setupName):
radioId = "RequestConsole_Dialog_LoadSetup_RadioButton_" + setupName radioId = "RequestConsole_Dialog_LoadSetup_RadioButton_" + setupName
loadButton = driver.wait.until(EC.element_to_be_clickable((By.ID, 'RequestConsole_Button_Load'))) loadButton = driver.wait.until(EC.element_to_be_clickable((By.ID, 'RequestConsole_Button_Load')))
loadButton.click() loadButton.click()
radioButton = driver.find_element_by_id(radioId) radioButton = driver.find_element(By.ID, radioId)
radioButton.click() radioButton.click()
dialogClickOk(driver, "LoadSetup") dialogClickOk(driver, "LoadSetup")
time.sleep(1) time.sleep(1)
...@@ -34,13 +34,13 @@ def dialogClickOk(driver, name): ...@@ -34,13 +34,13 @@ def dialogClickOk(driver, name):
button.click() button.click()
def getSetupName(driver): def getSetupName(driver):
label = driver.find_element_by_id("RequestConsole_SetupNameLabel") label = driver.find_element(By.ID, "RequestConsole_SetupNameLabel")
return label.text return label.text
def treeExists(driver, id): def treeExists(driver, id):
try: try:
div = driver.find_element_by_id(id) div = driver.find_element(By.ID, id)
div.find_element_by_class_name("jstree-node") div.find_element(By.CLASS_NAME, "jstree-node")
return True return True
except NoSuchElementException as e: except NoSuchElementException as e:
return False return False
...@@ -62,7 +62,7 @@ def sendRequest(driver): ...@@ -62,7 +62,7 @@ def sendRequest(driver):
def editorTypeExists(driver, className): def editorTypeExists(driver, className):
try: try:
driver.find_element_by_class_name(className) driver.find_element(By.CLASS_NAME, className)
return True return True
except NoSuchElementException as e: except NoSuchElementException as e:
return False return False
...@@ -104,7 +104,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase): ...@@ -104,7 +104,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase):
def test_requestEditorTree_dragAtomicRequestWithinTheRequestObject(self): def test_requestEditorTree_dragAtomicRequestWithinTheRequestObject(self):
init(self.driver, self.HTML_FILE) init(self.driver, self.HTML_FILE)
treeElements = self.driver.find_elements_by_xpath("//*[contains(@id, '_anchor')]") #for elem in treeElements: print elem.get_attribute('innerHTML') treeElements = self.driver.find_element(By.XPATH, "//*[contains(@id, '_anchor')]") #for elem in treeElements: print elem.get_attribute('innerHTML')
ActionChains(self.driver).drag_and_drop(treeElements[7], treeElements[8]).perform() ActionChains(self.driver).drag_and_drop(treeElements[7], treeElements[8]).perform()
script = "code_editor = $('#RequestConsole_CodeEditor .CodeMirror')[0].CodeMirror; return code_editor.getValue();" script = "code_editor = $('#RequestConsole_CodeEditor .CodeMirror')[0].CodeMirror; return code_editor.getValue();"
textInEditor = self.driver.execute_script(script) textInEditor = self.driver.execute_script(script)
...@@ -153,11 +153,11 @@ class RequestConsole_SetupHandlingTests(BaseTestCase): ...@@ -153,11 +153,11 @@ class RequestConsole_SetupHandlingTests(BaseTestCase):
def test_requestEditorTree_dragRequestFromHelpTree(self): def test_requestEditorTree_dragRequestFromHelpTree(self):
init(self.driver, self.HTML_FILE) init(self.driver, self.HTML_FILE)
treeElements = self.driver.find_elements_by_xpath("//*[contains(@id, '_anchor')]") treeElements = self.driver.find_element(By.XPATH, "//*[contains(@id, '_anchor')]")
ActionChains(self.driver).double_click(treeElements[0]).perform() ActionChains(self.driver).double_click(treeElements[0]).perform()
treeElementsAfterExpand = self.driver.find_elements_by_xpath("//*[contains(@id, '_anchor')]") treeElementsAfterExpand = self.driver.find_element(By.XPATH, "//*[contains(@id, '_anchor')]")
ActionChains(self.driver).drag_and_drop(treeElementsAfterExpand[1], treeElements[8]).perform() ActionChains(self.driver).drag_and_drop(treeElementsAfterExpand[1], treeElements[8]).perform()
script = "code_editor = $('#RequestConsole_CodeEditor .CodeMirror')[0].CodeMirror; return code_editor.getValue();" script = "code_editor = $('#RequestConsole_CodeEditor .CodeMirror')[0].CodeMirror; return code_editor.getValue();"
...@@ -234,7 +234,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase): ...@@ -234,7 +234,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase):
newSetup(self.driver); newSetup(self.driver);
addEmptyRequest(self.driver); addEmptyRequest(self.driver);
editorHeader = self.driver.find_element_by_id("RequestConsole_CodeEditor__Header") editorHeader = self.driver.find_element(By.ID, "RequestConsole_CodeEditor__Header")
editorHeaderColor = editorHeader.value_of_css_property("color") editorHeaderColor = editorHeader.value_of_css_property("color")
self.assertEqual('#000000', str(Color.from_string(editorHeaderColor).hex), 'RequestEditor\'s header should be black, it is ' + str(Color.from_string(editorHeaderColor).hex)) self.assertEqual('#000000', str(Color.from_string(editorHeaderColor).hex), 'RequestEditor\'s header should be black, it is ' + str(Color.from_string(editorHeaderColor).hex))
...@@ -245,7 +245,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase): ...@@ -245,7 +245,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase):
script = "a = '" + request + "';" + "code_editor = $('#RequestConsole_CodeEditor .CodeMirror')[0].CodeMirror; code_editor.setValue(a);" script = "a = '" + request + "';" + "code_editor = $('#RequestConsole_CodeEditor .CodeMirror')[0].CodeMirror; code_editor.setValue(a);"
self.driver.execute_script(script) self.driver.execute_script(script)
editorHeader = self.driver.find_element_by_id("RequestConsole_CodeEditor__Header") editorHeader = self.driver.find_element(By.ID, "RequestConsole_CodeEditor__Header")
editorHeaderColor = editorHeader.value_of_css_property("color") editorHeaderColor = editorHeader.value_of_css_property("color")
self.assertEqual('#000000', str(Color.from_string(editorHeaderColor).hex), 'RequestEditor header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex)) self.assertEqual('#000000', str(Color.from_string(editorHeaderColor).hex), 'RequestEditor header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex))
...@@ -256,7 +256,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase): ...@@ -256,7 +256,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase):
script = "a = '" + request + "';" + "code_editor = $('#RequestConsole_CodeEditor .CodeMirror')[0].CodeMirror; code_editor.setValue(a);" script = "a = '" + request + "';" + "code_editor = $('#RequestConsole_CodeEditor .CodeMirror')[0].CodeMirror; code_editor.setValue(a);"
self.driver.execute_script(script) self.driver.execute_script(script)
editorHeader = self.driver.find_element_by_id("RequestConsole_CodeEditor__Header") editorHeader = self.driver.find_element(By.ID, "RequestConsole_CodeEditor__Header")
editorHeaderColor = editorHeader.value_of_css_property("color") editorHeaderColor = editorHeader.value_of_css_property("color")
self.assertEqual('#ff0000', str(Color.from_string(editorHeaderColor).hex), 'RequestEditor\'s header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex)) self.assertEqual('#ff0000', str(Color.from_string(editorHeaderColor).hex), 'RequestEditor\'s header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex))
...@@ -273,7 +273,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase): ...@@ -273,7 +273,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase):
textInEditor = re.sub(r"\s", "", textInEditor) textInEditor = re.sub(r"\s", "", textInEditor)
self.assertEqual(request, textInEditor, "Response editor content can't be set") self.assertEqual(request, textInEditor, "Response editor content can't be set")
editorHeader = self.driver.find_element_by_id("RequestConsole_ResponseDisplay__Header") editorHeader = self.driver.find_element(By.ID, "RequestConsole_ResponseDisplay__Header")
editorHeaderColor = editorHeader.value_of_css_property("color") editorHeaderColor = editorHeader.value_of_css_property("color")
self.assertEqual('#000000', str(Color.from_string(editorHeaderColor).hex), 'ResponseDisplay header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex)) self.assertEqual('#000000', str(Color.from_string(editorHeaderColor).hex), 'ResponseDisplay header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex))
...@@ -284,7 +284,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase): ...@@ -284,7 +284,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase):
script = "a = '" + request + "';" + "code_editor = $('#RequestConsole_ResponseDisplay .CodeMirror')[0].CodeMirror; code_editor.setValue(a);" script = "a = '" + request + "';" + "code_editor = $('#RequestConsole_ResponseDisplay .CodeMirror')[0].CodeMirror; code_editor.setValue(a);"
self.driver.execute_script(script) self.driver.execute_script(script)
editorHeader = self.driver.find_element_by_id("RequestConsole_ResponseDisplay__Header") editorHeader = self.driver.find_element(By.ID, "RequestConsole_ResponseDisplay__Header")
editorHeaderColor = editorHeader.value_of_css_property("color") editorHeaderColor = editorHeader.value_of_css_property("color")
self.assertEqual('#ff0000', str(Color.from_string(editorHeaderColor).hex), 'ResponseDisplay header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex)) self.assertEqual('#ff0000', str(Color.from_string(editorHeaderColor).hex), 'ResponseDisplay header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex))
...@@ -293,7 +293,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase): ...@@ -293,7 +293,7 @@ class RequestConsole_SetupHandlingTests(BaseTestCase):
sendRequest(self.driver); sendRequest(self.driver);
editorHeader = self.driver.find_element_by_id("RequestConsole_ResponseDisplay__Header") editorHeader = self.driver.find_element(By.ID, "RequestConsole_ResponseDisplay__Header")
editorHeaderColor = editorHeader.value_of_css_property("color") editorHeaderColor = editorHeader.value_of_css_property("color")
self.assertEqual('#000000', str(Color.from_string(editorHeaderColor).hex), 'ResponseDisplay header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex)) self.assertEqual('#000000', str(Color.from_string(editorHeaderColor).hex), 'ResponseDisplay header should be red, it is ' + str(Color.from_string(editorHeaderColor).hex))
...@@ -346,4 +346,4 @@ class RequestConsole_SetupHandlingTests(BaseTestCase): ...@@ -346,4 +346,4 @@ class RequestConsole_SetupHandlingTests(BaseTestCase):
self.assertEqual(expectedResponse, textInEditor, "sendData is not returning the expexted result") self.assertEqual(expectedResponse, textInEditor, "sendData is not returning the expexted result")
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(catchbreak=True, verbosity=2) unittest.main(catchbreak=True, verbosity=2)
\ No newline at end of file
...@@ -8,18 +8,26 @@ ...@@ -8,18 +8,26 @@
#// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // #// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html //
#/////////////////////////////////////////////////////////////////////////////// #///////////////////////////////////////////////////////////////////////////////
#set -e
echo "Checking if Xvfb is running..." echo "Checking if Xvfb is running..."
XVFB_PID=`pgrep Xvfb` XVFB_PID=`pgrep Xvfb`
if [ "$?" == "0" ]; then if [ "$?" == "0" ]; then
echo "Xvfb is running, finding display port..." echo "Xvfb is running, finding display port..."
DISPLAY=`ps --format command --no-headers -ww --pid $XVFB_PID | grep -o ':[0-9]*'` DISPLAY=`ps --format command --no-headers -ww --pid $XVFB_PID | grep -o ':[0-9]*'`
echo "Found display port: "$DISPLAY echo "Found display port: "$DISPLAY
export DISPLAY=$DISPLAY.0 export DISPLAY=$DISPLAY.0
chmod u+x runTests.py chmod u+x runTests.py
./runTests.py
echo "INFO: Running the tests"
python3 runTests.py
if [ "$?" == "0" ]; then
echo "ERROR: Running of the tests failed"
exit 1
fi
exit 0 exit 0
...@@ -41,8 +49,11 @@ else ...@@ -41,8 +49,11 @@ else
export DISPLAY=:999.0 export DISPLAY=:999.0
chmod u+x runTests.py chmod u+x runTests.py
result=$(./runTests.py) result=$(python3 runTests.py)
echo $result if [ "$result" == "0" ]; then
echo "ERROR: Running of the tests failed. Exit status: $result"
exit 1
fi
killXvfb_trap killXvfb_trap
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // #// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html //
#/////////////////////////////////////////////////////////////////////////////// #///////////////////////////////////////////////////////////////////////////////
set -e
CURRENT_DIR=`pwd` CURRENT_DIR=`pwd`
#---COPY_TO="." #---COPY_TO="."
COPY_TO="./WebGUI" COPY_TO="./WebGUI"
...@@ -54,6 +56,8 @@ SELENIUM_LOC=$COPY_TO/htdocs/Selenium ...@@ -54,6 +56,8 @@ SELENIUM_LOC=$COPY_TO/htdocs/Selenium
MAIN_HTML=$COPY_TO/htdocs/Main.html MAIN_HTML=$COPY_TO/htdocs/Main.html
TEST_HETML=$COPY_TO/htdocs/Test.html TEST_HETML=$COPY_TO/htdocs/Test.html
echo "INFO: Preparation: deleting old files and copying"
# create target directory if it does not exist # create target directory if it does not exist
if [ ! -d $COPY_TO ]; then if [ ! -d $COPY_TO ]; then
mkdir $COPY_TO mkdir $COPY_TO
...@@ -89,6 +93,8 @@ cp -arL $TESTCASES_DIR/* $TESTCASES_LOC ...@@ -89,6 +93,8 @@ cp -arL $TESTCASES_DIR/* $TESTCASES_LOC
cp -arL $MOCKTEST_DSSERVERDESCRIPTOR $WEBAPP_LOC/MockTest/DsRestAPITestConfig.js cp -arL $MOCKTEST_DSSERVERDESCRIPTOR $WEBAPP_LOC/MockTest/DsRestAPITestConfig.js
echo "INFO: Creating Test.html file"
awk '{ awk '{
if ($0 ~ /FileHandler.js/) { if ($0 ~ /FileHandler.js/) {
sub("FileHandler.js", "DsRestAPI/MockedServer/FileHandler.js"); sub("FileHandler.js", "DsRestAPI/MockedServer/FileHandler.js");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment