Can we use Mobile Driver Factory(like web driver factory) and how to implement it


#1

If we need to add **import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory **for using driver factory then define WebDriver driver = DriverFactory.getWebDriver() to using driver for binary statement, how to use it on mobile testing and how to implement it ?
Tried many times but didn’t found solution, anyone know the solution please answer my question, thanks.


Method is not implemented for runIOSAppInBackgroundAndWait
#2

It should be like this:

import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.mobile.helper.MobileElementCommonHelper
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.util.KeywordUtil
import io.appium.java_client.AppiumDriver
AppiumDriver<?> driver = MobileDriverFactory.getDriver()

#3

thank you @Vinh Nguyen it’s working


#4

Vinh Nguyen said:

It should be like this:

import org.openqa.selenium.WebDriver

import org.openqa.selenium.WebElement
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.mobile.helper.MobileElementCommonHelper
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.util.KeywordUtil
import io.appium.java_client.AppiumDriver
AppiumDriver<?> driver = MobileDriverFactory.getDriver()


  

Hello,

I am using above same code for ImageComparison but i am getting error as :

FAILED because (of) java.lang.RuntimeException: org.openqa.selenium.WebDriverException: Method is not implemented (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 0 milliseconds
My Script looks like :

public class ScreenshotHelper {

@Keyword

def Test(String imgOriginal,String imgToCompareWithOriginal,String imgOutputDifferences) {

ImageComparison imageComparison = new ImageComparison(10,10,0.05);

if(Assert.assertTrue(imageComparison.fuzzyEqual(imgOriginal, imgToCompareWithOriginal, imgOutputDifferences))) {

//println(‘Images are fuzzy-equal’);

KeywordLogger log = new KeywordLogger()

log.logInfo(“Images are fuzzy-equal”)

}

else {

//println(‘Images are not fuzzy-equal’);

KeywordLogger log = new KeywordLogger()

log.logInfo(“Images are not fuzzy-equal”)

}

}

@Keyword

public void take(TestObject object)

{

MobileElement element = MobileElementCommonHelper.findElement(object, 20)

AppiumDriver<?> driver = MobileDriverFactory.getDriver()

Screenshot screenshot = new AShot().takeScreenshot(driver,element);

ImageIO.write(screenshot.getImage(),‘JPG’, new File(System.getProperty(“user.dir”)+"/image/ElementScreenshot.jpg"))

}

}

====
Please help me to resolve this issue.


#5

@Vinh_Nguyen Can you please help me to resolve this issue ? I am unable to run takescreenshot of mobile element using above code…

Thanks,
Pooja