Unable to capture "Choose File" as button object

Hi guys,
I want Katalon be able to click “Choose File” so that upload window gets opened.
ChooseFile

When running the test I get “Unable to click on object” error, I assume is because Katalon captured the object as Input, not as button. Using Upload File works, but is not an option for me.

How can I make Katalon click on Choose File, could you help on this?

hi,

is this web application or window application?
if web app then try to use css selector as locator

Hi Timo,

It’s a web application.
You mean to select CSS as locator on the object? selected it, but it’s empty and got this message when running the test… Unable to find the element located by 'By.cssSelector: '. Please recheck the objects properties to make sure the desired element is located.

Hi,


and after string copied
select CSS in KS
and add selector to it

Hi,

This is the selector I found and copy/paste into Katalon, but doesn’t work, still get error “unable to click object…”
image

In the HTML of your target web page, the value of id attribute:

_FOpt1:_For1:0:_FOSritemNode_tools_migration_find1:0:_FOTsr1:0:r1:0:if1::content

Is it static? or dynamic?

Does it stays the same even when you refreshed the page view on browser? or does it change?

It stays the same

Could you share the HTML source of the target page? We need see the portion from the 1st line of HTML down to the target <input> element.

Don’t you have <iframe> around the target <input> element? If yes, see

It can be a case that you need to wait for some seconds before the target <input> element become clickable. Please try inserting WebUI.delay(3) before “WebUI.click(…)”.

Have tried this too, but doesn’t “want” to click on it

hi,

are you able to spy this object by KS tool?

I guess as follows.

When you operate on a Browser window manually, you would follow the following steps.

  1. you click Migration button rather than Appearance button
  2. you click Incoming tag rather than Outgoing tab
  3. you click ChooseFile button

Please note you (possibly) need to do #1 and #2 before you do #3.

Does your test script follow #1, #2 and #3 just like you do manually?

If your test script tries to do #3 soon after it starts without doing #1 and #2, then the “Choose File” button will not be visible. While the “Choose File” button is invisible, it will not be clickable. Then you would see “Unable to click on object” error.

Hi,
I’m able to spy the object, but Katalon always saves it as input object not button object. I assume that is why it’s unable to click it.

Hi,
I’m following steps #1, #2, #3 and ChooseFile is visible when landing on "Incoming’’ page. I also put a 3 sec delay before click Choose File, but for some reason is unable to click it

You need to break down your problem.

The primary question would be if your selector is 100% right, or wrong.

You should validate your XPath/CSS selectors using tools other than Katalon Studio.

The best choice is Chrome Developer Tools. Have a look at the following article.

(quoting from https://stackoverflow.com/questions/3030487/is-there-a-way-to-get-the-xpath-in-google-chrome)

You can easily get XPath of the HTML element of your interest

From Chrome :

  1. Right click “inspect” on the item you are trying to find the xpath
  2. Right click on the highlighted area on the console.
  3. Go to Copy xpath

enter image description here

By the way, if your test case successfuly click the “Choose File” button, what do you expect to happen?

Is your testcase script coded ready to detect if your expectation fulfilled? How do you distinguish if the button is clicked or not?

Hi,
I have tried below 3 scenarios to make Katalon click Choose File object, but didn’t succeed. Please let me know if I’m missing something and thank you for trying to help me out.

Scenario 1
I have used Record, but have also tried Spy to save the object. Both ways led me to Xpath: //input[@id=‘_FOpt1:_FOr1:0:_FOSritemNode_tools_migration_fnd1:0:_FOTsr1:0:r1:0:if1::content’]
When running the test, even though I land on “Incoming” page and Choose File is visible, Katalon is unable to Click on object.
CSS Selected Locator is empty by default when using Record/Spy.

Scenario 2
2.1 Have navigated to locate my desired object (Choose File) with Inspect Page > right-click highlighted area > Copy > Copy Xpath:
//*[@id=“_FOpt1:_FOr1:0:_FOSritemNode_tools_migration_fnd1:0:_FOTsr1:0:r1:0:if1::content”]
Then copy/pasted into Katalon as Xpath Selected Locator, run the test, but still unable to click the object.
2.2 Inspected page again, this time to identify CSS selector, right-click highlighted area > Copy > Copy Selector:
#_FOpt1:_FOr1:0:_FOSritemNode_tools_migration_fnd1:0:_FOTsr1:0:r1:0:if1::content
Copy/pasted into Katalon as CSS Selected Locator, run the test, still unable to click the object.

Scenario 3
Have installed SelectorGadget Chrome Extension and went again through scenarios 2.1 and 2.2.
This got me identifying same Xpath and CSS selectors as when using Inspect.

If my test case successfully clicks the Choose File button, I expected windows file to get opened like this:

I don’t have script for next step (click to select specific file). Was planning to investigate how to do that after I get Katalon click on Choose File. (suppose I can use Record Windows Action functionality?)

I’m looking now into Chrome DevTools that you sugested, hope I can make use of it.

Could you try to make an assertion that the code successfully selected the element by invoking WebUI.verifyElementPresent() like this:

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
...
TestObject tObj = findTestObject("the name of TestObject pointing ChooseFile input element")
...
WebUI.verifyElementPresent(tObj, 5, FailureHandling.STOP_ON_FAILURE)
WebUI.click(tObj)
...

When you run this, does “WebUI.verifyElementPresent()” fail or pass?

If it fails, you need to continue trying to find out why you can not find the <input> element.

If it passes, then the code will surely reach to the “WebUI.click()” statement but not actually clicking the element.

Which case?