Hi All,
Scenario : To upload/provide an input such as an image from the local device to sauce labs with the image injection feature to perform automated tests
i’m trying to perform an action such as image injection, i.e providing an local image path in Katalon and supplying that as an input to the remote device in sauce labs,
link - Camera Image Injection | Sauce Labs Documentation
As per the above link from sauce labs, if we configure the code like this, we can achieve image injection but even though we have written the code, we are getting an error(Attached file)
Can you please suggest how the code can be changed or any alternate scenario which provides image injection from Katalon studio to sauce labs remote devices?
Please let me know in case you need any other details, Below is the groovy code written in Katalon studio by creating a method:
import java.util.Base64 as Base64
import java.nio.file.Files as Files
import java.nio.file.Paths as Paths
import org.openqa.selenium.JavascriptExecutor as JavascriptExecutor
import java.io.FileInputStream as FileInputStream
import static org.apache.commons.io.IOUtils.toByteArray
Mobile.startExistingApplication('cargill.com.digitalsaathi')
Mobile.scrollToText(GlobalVariable.homeHeading, FailureHandling.OPTIONAL)
Mobile.tap(findTestObject('Object Repository/Application/Object_Collection/My Chat/Home Icon - Chat withExpert(paid)'), 0)
Mobile.waitForElementPresent(findTestObject('Application/Object_Collection/My Chat/Chat - Camera Icon (1)'), 0)
// Use executeScript with sauce:inject-image command to inject the image
def imagePath = '/Users/pathFolder/Execute_Test_case.png'
String base64ImageString = Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(imagePath)))
((Mobile) as JavascriptExecutor).executeScript('sauce:inject-image=' + base64ImageString, findTestObject('Application/Object_Collection/My Chat/Chat - Camera Icon (1)'))
Mobile.waitForElementPresent(findTestObject('Application/Object_Collection/My Chat/Chat - Camera Icon (1)'), 0)
Mobile.tap(findTestObject('Application/Object_Collection/My Chat/Chat - Camera Icon (1)'), 0)
Mobile.waitForElementPresent(findTestObject('Application/Object_Collection/My Chat/Chat - Camera Capture option'), 0)
not_run: Mobile.closeApplication()
Error Log:
07-20-2023 03:42:14 PM Test Cases/Digital_Saathi_V4.2/Chat with Expert/Chat_new
Elapsed time: 32.961s
Test Cases/Digital_Saathi_V4.2/Chat with Expert/Chat_new FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords.executeScript() is applicable for argument types: (java.lang.String, [Ljava.lang.Object;) values: [sauce:inject-image=iVBORw0KGgoAAAANSUhEUgAABpAAAAG6CAYAAAAPswUfAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAqduSURBVHgB7J0HYBRFG4bfq0kuvRdqQgmh996kg4B0sYAgYBdBEQv2BioKPxYsKE1URERBLID03nuHAAmk955r/
Thanks,
Sudarshan