Monday, May 6, 2024
HomeiOS Developmentandroid - AppiumWebDriverEventListener not working with katalon

android – AppiumWebDriverEventListener not working with katalon


Have a great day.

I’m utilizing the beneath class to pay attention for clicks and usages. and code getting used for hybrid app that works on each android and iOS.

Code for listener in katalon

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import org.openqa.selenium.By
import org.openqa.selenium.OutputType
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement

import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.mannequin.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject

import com.kms.katalon.core.webservice.key phrase.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.key phrase.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.cellular.key phrase.MobileBuiltInKeywords as Cell

import inner.GlobalVariable
import io.appium.java_client.occasions.api.normal.AppiumWebDriverEventListener
import com.kms.katalon.core.annotation.BeforeTestCase
import com.kms.katalon.core.annotation.BeforeTestSuite
import com.kms.katalon.core.annotation.AfterTestCase
import com.kms.katalon.core.annotation.AfterTestSuite
import com.kms.katalon.core.context.TestCaseContext
import com.kms.katalon.core.context.TestSuiteContext

class ClickEventListener implements AppiumWebDriverEventListener {

    @Override
    public void afterAlertAccept(WebDriver arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterAlertDismiss(WebDriver arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterChangeValueOf(WebElement arg0, WebDriver arg1, CharSequence[] arg2) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterClickOn(WebElement arg0, WebDriver arg1) {
        System.out.println("afterClickOn ---");
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterFindBy(By arg0, WebElement arg1, WebDriver arg2) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public <X> void afterGetScreenshotAs(OutputType<X> arg0, X arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterGetText(WebElement arg0, WebDriver arg1, String arg2) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterNavigateBack(WebDriver arg0) {
        
        System.out.println("navigate again <---");
        
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterNavigateForward(WebDriver arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterNavigateRefresh(WebDriver arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterNavigateTo(String arg0, WebDriver arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterScript(String arg0, WebDriver arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterSwitchToWindow(String arg0, WebDriver arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeAlertAccept(WebDriver arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeAlertDismiss(WebDriver arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeChangeValueOf(WebElement arg0, WebDriver arg1, CharSequence[] arg2) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeClickOn(WebElement arg0, WebDriver arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeFindBy(By arg0, WebElement arg1, WebDriver arg2) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public <X> void beforeGetScreenshotAs(OutputType<X> arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeGetText(WebElement arg0, WebDriver arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeNavigateBack(WebDriver arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeNavigateForward(WebDriver arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeNavigateRefresh(WebDriver arg0) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeNavigateTo(String arg0, WebDriver arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeScript(String arg0, WebDriver arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeSwitchToWindow(String arg0, WebDriver arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void onException(Throwable arg0, WebDriver arg1) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void beforeChangeValueOf(WebElement var1, WebDriver var2) {
        // TODO Auto-generated technique stub
        
    }

    @Override
    public void afterChangeValueOf(WebElement var1, WebDriver var2) {
        // TODO Auto-generated technique stub
        
    }
  
    
    
}

and that is the code for take a look at case, wherein I’ve registerd the take a look at listener there (simply temorary)

AndroidDriver<?> driver = MobileDriverFactory.getDriver()

// Create an occasion of your ClickEventListener class
ClickEventListener clickListener = new ClickEventListener();
EventFiringWebDriver eventFiringDriver = new EventFiringWebDriver(driver);
eventFiringDriver.register(clickListener)




Cell.pressBack()

String loginButtonSource = "Object Repository/StartPage/loginButton";
TestObject loginButton = findTestObject(loginButtonSource)

Cell.faucet(loginButton, 10, FailureHandling.CONTINUE_ON_FAILURE)

I’ve tried to check strategies [afterClickOn, afterNavigateBack] however they aren’t fired.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments