Skip to content

Commit

Permalink
implemented com.kazurayam.ksbackyard.HighlightElement#pandemic method
Browse files Browse the repository at this point in the history
  • Loading branch information
kazurayam committed Jan 10, 2019
1 parent af80707 commit f6bacd7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 94 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

/bin/

/Reports
/Reports

/Libs
29 changes: 16 additions & 13 deletions Keywords/com/kazurayam/ksbackyard/HighlightElement.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,10 @@ 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.builtin.SetTextKeyword
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords
import com.kms.katalon.core.keyword.internal.KeywordExecutor

public class HighlightElement {

@Keyword
public static void onAny() {
SetTextKeyword.metaClass.'static'.invokeMethod = { Object object, String name, Object[] args ->
println "${name} invoked"
if (name =~ /setText/) {
TestObject testObject = (TestObject)args[0]
HighlightElement.on(testObject)
}
return super.invokeMethod(object, name, args)
}
}

@Keyword
public static void on(TestObject testObject) {
Expand All @@ -45,4 +34,18 @@ public class HighlightElement {
e.printStackTrace()
}
}

/**
* overwride methods of WebUiBuiltInKeywords so that they call HighlightElement.on(testObject).
* http://docs.groovy-lang.org/latest/html/documentation/core-metaprogramming.html#metaprogramming_emc
*/
@Keyword
public static void pandemic() {
// setText()
WebUiBuiltInKeywords.metaClass.static.setText = { TestObject to, String text ->
HighlightElement.on(to)
KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.PLATFORM_WEB, "setText", to,text)
}
}

}

This file was deleted.

This file was deleted.

8 changes: 4 additions & 4 deletions Libs/CustomKeywords.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import com.kms.katalon.core.testobject.TestObject


def static "com.kazurayam.ksbackyard.HighlightElement.onAny"() {
(new com.kazurayam.ksbackyard.HighlightElement()).onAny()
}

def static "com.kazurayam.ksbackyard.HighlightElement.on"(
TestObject testObject ) {
(new com.kazurayam.ksbackyard.HighlightElement()).on(
testObject)
}

def static "com.kazurayam.ksbackyard.HighlightElement.pandemic"() {
(new com.kazurayam.ksbackyard.HighlightElement()).pandemic()
}
4 changes: 2 additions & 2 deletions Scripts/TC1/Script1547070867765.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.pandemic'()

WebUI.openBrowser('')

WebUI.navigateToUrl('https://katalon-demo-cura.herokuapp.com/')
Expand All @@ -24,8 +26,6 @@ CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(findTestObject('Ob

WebUI.delay(1)

CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.onAny'()

WebUI.click(findTestObject('Object Repository/Page_CURA Healthcare Service/a_Make Appointment'))

WebUI.delay(1)
Expand Down

0 comments on commit f6bacd7

Please sign in to comment.