Katalon Studio Native Popup Window and Upload File


#21

Hello Again @rushantha

1.Step : Please refresh the keyword folder.

2.Step : Open your Test Case page and add a custom keyword from the ADD field.


#22

It’s missing @Keyword before def uploadFile(TestObject tp, String filePath)


#23

Hello @HeleneB

In the custom keyword definition, the relevant phrase exists, has it added? couldn’t tell where missing.


#24

Thanks @emine… you did great help for me… thanks a lot… now it is successfully happening…:grinning::grinning::grinning::+1::+1:


#25

@HeleneB… Thanks .i added it and now it is working prefectly.:grinning::+1:


#26

@rushantha Hello Again
You’re welcome. If there’s something I can help you with, you can send it back.


#27

sure…:+1:


#28

I am also trying this solution , but seems it is not working for me aswell,

GenericActions.uploadFile(findTestObject(‘Object Repository/Banner/applicationNavigator/SZADOCS/Page_Application Navigator/upload_button’),‘C:\Users\shilpi\Upload test.docx’)

upload class–
def static uploadFile(TestObject to, String filePath) {
WebUI.click(to)
StringSelection ss = new StringSelection(filePath)
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null)
Robot robot = new Robot()
robot.keyPress(KeyEvent.VK_ENTER)
robot.keyRelease(KeyEvent.VK_ENTER)
robot.keyPress(KeyEvent.VK_CONTROL)
robot.keyPress(KeyEvent.VK_V)
robot.keyRelease(KeyEvent.VK_V)
robot.keyRelease(KeyEvent.VK_CONTROL)
robot.keyPress(KeyEvent.VK_ENTER)
robot.keyRelease(KeyEvent.VK_ENTER)
}


#29

It is working for me… Sometimes it is getting stuck…but most of the time it is working


(TEST DATA) Define specific Excel Sheets to get Excel Values
#30

Do we need to dd any plugin for this? bcz I hvnt.


#31

I have element which get active on mouse hover.
First I have to hover mouse on element then upload files by click on that.
Three Actions at a time …please guide…
Mouse Hover, click and file upload


#32

Can you please read and try with methods in this topic :slightly_smiling_face:Katalon Studio Native Popup Window and Upload File


#33

Ya I tried, its not working that may be because here I need to perform mouse hover first


#34

fixed, its working now…Thanks guys:)


#35

“Unable to upload file”

my custom keyword

package upload

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 com.kms.katalon.core.annotation.Keyword

import com.kms.katalon.core.checkpoint.Checkpoint

import com.kms.katalon.core.checkpoint.CheckpointFactory

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords

import com.kms.katalon.core.model.FailureHandling

import com.kms.katalon.core.testcase.TestCase

import com.kms.katalon.core.testcase.TestCaseFactory

import com.kms.katalon.core.testdata.TestData

import com.kms.katalon.core.testdata.TestDataFactory

import com.kms.katalon.core.testobject.ObjectRepository

import com.kms.katalon.core.testobject.TestObject

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords

import internal.GlobalVariable

import MobileBuiltInKeywords as Mobile

import WSBuiltInKeywords as WS

import WebUiBuiltInKeywords as WebUI

import org.openqa.selenium.WebElement

import org.openqa.selenium.WebDriver

import org.openqa.selenium.By

import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory

import com.kms.katalon.core.webui.driver.DriverFactory

import com.kms.katalon.core.testobject.RequestObject

import com.kms.katalon.core.testobject.ResponseObject

import com.kms.katalon.core.testobject.ConditionType

import com.kms.katalon.core.testobject.TestObjectProperty

import com.kms.katalon.core.mobile.helper.MobileElementCommonHelper

import com.kms.katalon.core.util.KeywordUtil

import com.kms.katalon.core.webui.exception.WebElementNotFoundException

import java.awt.Robot

import java.awt.Toolkit

import java.awt.datatransfer.StringSelection

import java.awt.event.KeyEvent

class uploadclass {

/**

  • Refresh browser

*/

@Keyword

def uploadFile (TestObject to, String filePath) {

WebUI.click(to)

StringSelection ss = new StringSelection(filePath);

Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);

Robot robot = new Robot();

robot.keyPress(KeyEvent.VK_ENTER);

robot.keyRelease(KeyEvent.VK_ENTER);

robot.keyPress(KeyEvent.VK_CONTROL);

robot.keyPress(KeyEvent.VK_V);

robot.keyRelease(KeyEvent.VK_V);

robot.keyRelease(KeyEvent.VK_CONTROL);

robot.keyPress(KeyEvent.VK_ENTER);

robot.keyRelease(KeyEvent.VK_ENTER);

}

}

the script:

WebUI.callTestCase(findTestCase(‘Self Sender/01. Login’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject(‘nuovo mezzo/Page_C Scrivania/span_Mezzi’))

WebUI.click(findTestObject(‘nuovo mezzo/Page_C Mezzi/button_Nuovo mezzo’))

WebUI.setText(findTestObject(‘nuovo mezzo/Page_C Nuovo mezzo/input_Targa_vehicle_plate’), ‘2aaasdfgh’)

WebUI.click(findTestObject(‘nuovo mezzo/Page_C Nuovo mezzo/button_Anno del mezzo’))

WebUI.setText(findTestObject(‘nuovo mezzo/Page_C Nuovo mezzo/anno_mezzo’), ‘2019’)

WebUI.click(findTestObject(‘nuovo mezzo/Page_C Nuovo mezzo/seleziona_data’))

WebUI.click(findTestObject(‘nuovo mezzo/Page_C Nuovo mezzo/button_Classe mezzo’))

WebUI.click(findTestObject(‘nuovo mezzo/Page_C Nuovo mezzo/a_Autocarro’))

WebUI.click(findTestObject(‘nuovo mezzo/Page_C Nuovo mezzo/button_Configurazione mezzo’))

WebUI.click(findTestObject(‘nuovo mezzo/Page_C Nuovo mezzo/a_Cabinato’))

WebUI.click(findTestObject(‘nuovo mezzo/Page_C Nuovo mezzo/button_Salva’))

WebUI.click(findTestObject(‘edit mezzo/Page_C Mezzi/button_ok’))

WebUI.setText(findTestObject(‘elimna mezzo/Page_C Mezzi/input_Capacit di carico_form-control’), ‘2’)

WebUI.click(findTestObject(‘edit mezzo/Page_C Mezzi/td_2aaasdfgh’))

WebUI.click(findTestObject(‘edit mezzo/Paage_C Dettaglio mezzo/button_Nessun driver predefinito’))

WebUI.click(findTestObject(‘edit mezzo/Page_C Dettaglio mezzo/a_demo 102 autista’))

WebUI.click(findTestObject(‘edit mezzo/Page_C Dettaglio mezzo/input_Foto mezzo_vehicle_cover’))

CustomKeywords.‘upload.uploadclass.uploadFile’(findTestObject(‘Datalocker/Add-Dataset-Button’), ‘/Users/…/img.jpg’)

WebUI.click(finTestObject(‘Datalocker/Add-Dataset-Button’))


#36

Hi, so i used the keyword and it navigates to the path but does not find my file any assistance please


#37

Ok cool i managed to sort my issue out, added in a delay after the custom keyword , maybe it couldnt find the file that quick.


#38

This post really helpfull. Thank you soo much


#39

I’m new to these languages and this application, so forgive me if some of the below is nonsense/unnecessary.

For others who may still be having an issue, I believe my issue was that I had previously tried to implement the plugin from the Katalon Store and it was somehow conflicting with my new keyword (maybe I was using the same keyword). This is how I followed this tutorial and resolved the error I don’t see mentioned above:

  • go to Katalon Store and uninstall “Upload” plugin.
  • remove any upload step from script or manual execution (you replace it at the end of these steps)
  • remove any custom package and keyword you attempted to create from Keywords in project explorer
  • maybe cleanup project
  • restart Katalon Studio
  • recreate new package in keywords
  • recreate new keyword in that package
  • refresh Keywords and Project (not sure if they are two different functions)
  • add custom keyword back to test case (this time it should look closer to the tutuorial)

Thanks @emine for the guide. I would like to see some more images though, especially showing what manual and script execution window looks like after it’s configured correctly and without tooltips.


#40

I am able to Open File explorer and select the desired file with what you provided. However, windows explorer stays open. How can I get it to click the open button?