From e30317479eb1a9174f173e1f33c5be7458e6d7b4 Mon Sep 17 00:00:00 2001 From: kazurayam Date: Thu, 28 Nov 2024 07:27:55 +0900 Subject: [PATCH] resolved merge conflicts --- .../ksbackyard/HighlightElement.groovy | 174 ++---------------- Scripts/TC1/Script1547070867765.groovy | 23 +-- Test Cases/TC0.tc | 7 +- Test Cases/TC1.tc | 1 - Test Suites/TS1.ts | 2 + 5 files changed, 17 insertions(+), 190 deletions(-) diff --git a/Keywords/com/kazurayam/ksbackyard/HighlightElement.groovy b/Keywords/com/kazurayam/ksbackyard/HighlightElement.groovy index 7f696a9..819ae37 100644 --- a/Keywords/com/kazurayam/ksbackyard/HighlightElement.groovy +++ b/Keywords/com/kazurayam/ksbackyard/HighlightElement.groovy @@ -5,34 +5,24 @@ import org.openqa.selenium.WebDriver import org.openqa.selenium.WebElement import com.kms.katalon.core.annotation.Keyword +import com.kms.katalon.core.keyword.internal.KeywordExecutor +import com.kms.katalon.core.model.FailureHandling import com.kms.katalon.core.testobject.TestObject import com.kms.katalon.core.webui.common.WebUiCommonHelper import com.kms.katalon.core.webui.driver.DriverFactory import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords -/** - * This class implements 2 Keyword methods for Katalon Studio. - * - * HighlightElement.on(TestObject to) puts highlight on the specified HTML element. - * - * HighlightElement.pandemic() and HighlightElement.pandemic(List keywordsToAdd) modifies some built-in WebUI Keywords dynamically so that they implicity invoke .on(TestObject) before - executing their own built-in processing (such as clicking the element). - */ public class HighlightElement { @Keyword public static void on(TestObject testObject) { - drawOutline(testObject) + influence(testObject) } -<<<<<<< HEAD - private static void drawOutline(TestObject testObject) { -======= private static String DEFAULT_STYLE = 'outline: dotted red' private static String highlightingStyle = DEFAULT_STYLE private static void influence(TestObject testObject) { ->>>>>>> develop try { WebDriver driver = DriverFactory.getWebDriver() List elements = WebUiCommonHelper.findWebElements(testObject, 20); @@ -47,181 +37,40 @@ public class HighlightElement { } } - /** - * @return list of the built-in WebUI.* keywords that have "TestObject" as the 1st argument. - */ - public static Set getHighlightableBuiltinKeywords() { - List metaMethods = WebUiBuiltInKeywords.metaClass.getMethods() - //println "metaMethods.size() is ${metaMethods.size()}" - Set highlightables = new HashSet() - for (MetaMethod method in metaMethods) { - if (method.isStatic() && method.isPublic()) { - Class[] parameterTypes = method.nativeParameterTypes - // select a Keyword if it requires a TestObject as the 1st argument - if ( parameterTypes.size() > 0 && parameterTypes[0].is(TestObject.class)) { - //println "method: ${method.getName()}(${parameterTypes[0].getName()})" - highlightables.add(method.getName()) - } - } - } - return highlightables - } - - - /** - * these keywords are "highlighting" as default - */ - public static final Set DEFAULT_HIGHLIGHTING_KW = new HashSet([ + private static List influencedKeywords = [ 'click', 'selectOptionByIndex', 'selectOptionByLabel', 'selectOptionByValue', 'setEncryptedText', 'setText' -<<<<<<< HEAD - ]) - - // instance variable - private final Set highlightingKW - - /** - * constructor - */ - HighlightElement() { - this.highlightingKW = new HashSet(DEFAULT_HIGHLIGHTING_KW) - } -======= ] ->>>>>>> develop /** * change some of methods of WebUiBuiltInKeywords so that they call HighlightElement.on(testObject) * before invoking their original method body. -<<<<<<< HEAD - * - * This method is implemented using Groovy Metaprogramming technique. See -======= * ->>>>>>> develop * http://docs.groovy-lang.org/latest/html/documentation/core-metaprogramming.html#metaprogramming - * - * @param keywordsToAdd you can specify additional keywords to turn "highlighting" */ @Keyword -<<<<<<< HEAD - public void pandemic(List keywordsToAdd = []) { - this.markKeywords(keywordsToAdd) - Set influencedKeywords = this.getHighlightingKeywords() -======= public static void pandemic(String style, List keywords) { highlightingStyle = style influencedKeywords.addAll(keywords) ->>>>>>> develop WebUiBuiltInKeywords.metaClass.'static'.invokeMethod = { String name, args -> if (name in influencedKeywords) { TestObject to = (TestObject)args[0] HighlightElement.on(to) } - return delegate.metaClass.getMetaMethod(name, args).invoke(delegate, args) - } - } - -<<<<<<< HEAD - /** - * - * @param keywordsToAdd - */ - public void markKeywords(List keywordsToAdd = []) { - Objects.requireNonNull(keywordsToAdd) - Set highlightables = getHighlightableBuiltinKeywords() - keywordsToAdd.each { kw -> - // if the specified keyword is highlight-able, then accept it - if (highlightables.contains(kw)) { - //println "specified keyword \"${kw}\" is marked as highlight-able" - this.highlightingKW.add(kw) - } else { - println "specified keyword \"${kw}\" is not highlight-able; just ignored" + def result + try { + result = delegate.metaClass.getMetaMethod(name, args).invoke(delegate, args) + } catch(Exception e) { + System.out.println("Handling exception for method $name") } + return result } } - /** - * - * @return - */ - public Set getHighlightingKeywords() { - return highlightingKW.clone() - } - - - // previous implementation of pandemic without Groovy's Metaprogramming - /* - @Keyword - public static void pandemic() { - // click() with FailuraHandling - WebUiBuiltInKeywords.metaClass.static.click = { TestObject to, FailureHandling flowControl -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "click", to, flowControl) - } - // click() without FailuraHandling - WebUiBuiltInKeywords.metaClass.static.click = { TestObject to -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "click", to) - } - // selectOptionByIndex() with FailureHandling - WebUiBuiltInKeywords.metaClass.static.selectOptionByIndex = { TestObject to, Object range, FailureHandling flowControl -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "selectOptionByIndex", to, range, flowControl) - } - // selectOptionByIndex() without FailureHandling - WebUiBuiltInKeywords.metaClass.static.selectOptionByIndex = { TestObject to, Object range -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "selectOptionByIndex", to, range) - } - // selectOptionByLabel() with FailureHandling - WebUiBuiltInKeywords.metaClass.static.selectOptionByLabel = { TestObject to, String value, boolean isRegex, FailureHandling flowControl -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "selectOptionByLabel", to, value, isRegex, flowControl) - } - // selectOptionByLabel() without FailureHandling - WebUiBuiltInKeywords.metaClass.static.selectOptionByLabel = { TestObject to, String value, boolean isRegex -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "selectOptionByLabel", to, value, isRegex) - } - // selectOptionByValue() with FailureHandling - WebUiBuiltInKeywords.metaClass.static.selectOptionByValue = { TestObject to, String value, boolean isRegex, FailureHandling flowControl -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "selectOptionByValue", to, value, isRegex, flowControl) - } - // selectOptionByValue() without FailureHandling - WebUiBuiltInKeywords.metaClass.static.selectOptionByValue = { TestObject to, String value, boolean isRegex -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "selectOptionByValue", to, value, isRegex) - } - // setEncryptedText() with FailureHandling - WebUiBuiltInKeywords.metaClass.static.setEncryptedText = { TestObject to, String encryptedText, FailureHandling flowControl -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "setEncryptedText", to, encryptedText, flowControl) - } - // setEncryptedText() without FailureHandling - WebUiBuiltInKeywords.metaClass.static.setEncryptedText = { TestObject to, String encryptedText -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "setEncryptedText", to, encryptedText) - } - // setText() with FailureHandling - WebUiBuiltInKeywords.metaClass.static.setText = { TestObject to, String text, FailureHandling flowControl -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "setText", to, text, flowControl) - } - // setText() without FailureHandling - WebUiBuiltInKeywords.metaClass.static.setText = { TestObject to, String text -> - HighlightElement.on(to) - KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "setText", to, text) - } - } - */ -} -======= @Keyword public static void pandemic() { pandemic(DEFAULT_STYLE, []) @@ -236,5 +85,4 @@ public class HighlightElement { public static void pandemic(List keywords) { pandemic(DEFAULT_STYLE, keywords) } -} ->>>>>>> develop +} \ No newline at end of file diff --git a/Scripts/TC1/Script1547070867765.groovy b/Scripts/TC1/Script1547070867765.groovy index 1bdcc9e..3a59651 100644 --- a/Scripts/TC1/Script1547070867765.groovy +++ b/Scripts/TC1/Script1547070867765.groovy @@ -5,29 +5,17 @@ import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI /** * TC1 -<<<<<<< HEAD - */ -======= - * - * This script visits the page at https://katalon-demo-cura.herokuapp.com/ + * + * This script visits the page at https://katalon-demo-cura.herokuapp.com/ * and the linked pages while highlighting elements with red border. * This script repeats explicitly calling a custome keyword to put the highlight * so that this script looks tedius. */ ->>>>>>> develop // open browser and navigate to the AUT WebUI.openBrowser('') WebUI.setViewPortSize(1024, 1024) WebUI.navigateToUrl('https://katalon-demo-cura.herokuapp.com/') -<<<<<<< HEAD - -// modify WebUI.* keywords which take TestObject as arg0 -// so that they call Highlight.on() automatically -CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.pandemic'() - -WebUI.click(findTestObject('Page_CURA Healthcare Service_top/a_Make Appointment')) -======= WebUI.delay(1) TestObject h1_CURA = findTestObject('Page_CURA Healthcare Service_top/h1_CURA Healthcare Service') @@ -40,7 +28,6 @@ WebUI.verifyElementPresent(a_MakeAppointment, 10) // highlight the element CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(a_MakeAppointment) WebUI.click(a_MakeAppointment) ->>>>>>> develop WebUI.delay(1) TestObject input_username = findTestObject('Page_CURA Healthcare Service_login/input_Username_username') @@ -63,13 +50,9 @@ CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(select_Facility) WebUI.selectOptionByIndex(select_Facility, 0) WebUI.delay(1) -<<<<<<< HEAD -WebUI.click(findTestObject('Page_CURA Healthcare Service_appointment/input_Apply for hospital readm')) -======= TestObject input_hospital_readm = findTestObject('Page_CURA Healthcare Service_appointment/input_Apply for hospital readm') CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(input_hospital_readm) WebUI.click(input_hospital_readm) ->>>>>>> develop WebUI.delay(1) TestObject input_Medicaid = findTestObject('Page_CURA Healthcare Service_appointment/input_Medicaid_programs') @@ -97,4 +80,4 @@ CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(a_Go_to_Homepage) WebUI.click(a_Go_to_Homepage) WebUI.delay(1) -WebUI.closeBrowser() +WebUI.closeBrowser() \ No newline at end of file diff --git a/Test Cases/TC0.tc b/Test Cases/TC0.tc index 82bb5e4..f64e1df 100644 --- a/Test Cases/TC0.tc +++ b/Test Cases/TC0.tc @@ -4,10 +4,5 @@ TC0 -<<<<<<< HEAD - acc23931-de48-4b92-a6be-771f1804f416 -======= - OTHER - 78b3ca65-5cb5-4a9e-b949-e19dbccff62a ->>>>>>> develop + dc80fd5a-b8cf-4535-a917-1959603a772c diff --git a/Test Cases/TC1.tc b/Test Cases/TC1.tc index 97be4dc..56b9bf9 100644 --- a/Test Cases/TC1.tc +++ b/Test Cases/TC1.tc @@ -4,6 +4,5 @@ TC1 - OTHER d58ff4fd-fb65-4bf0-aa81-58c745a3616b diff --git a/Test Suites/TS1.ts b/Test Suites/TS1.ts index 7b4eb67..dd3fcf5 100644 --- a/Test Suites/TS1.ts +++ b/Test Suites/TS1.ts @@ -16,6 +16,7 @@ false true Test Cases/TC0 + true 8ad65bd7-b4bf-4e6f-8219-a89f05659de9 @@ -29,5 +30,6 @@ false true Test Cases/TC2 + true