Unable to capture "Choose File" as button object

Yes, it’s unable to start with Firefox. There are some Katalon forum topics related to “Cannot find firefox binary in PATH”, looking now into them.
Cannot find firefox binary in PATH.txt (8.6 KB)

document.querySelector("#_FOpt1\\:_For1\\:0\\:_FOSritemNode_tools_migration_fnd1\\:0\\:_FOTsr1\\:0\\:r1\\:0\\:if1\\:\\:content").click()

Try doubling the slashes. And don’t forget the “#” at the start (I did!)

In the ConsoleOutput.txt you attached, I found:

2020-04-15 11:01:30.580 DEBUG testcase.CSM_Process_Incoming_Simona     - 11: result = verifyElementPresent(tObj, 5, CONTINUE_ON_FAILURE)
2020-04-15 11:01:38.729 DEBUG testcase.CSM_Process_Incoming_Simona     - 12: if (result)
2020-04-15 11:01:38.730 DEBUG testcase.CSM_Process_Incoming_Simona     - 1: comment("Element is successfully found: " + tObj.toString())
2020-04-15 11:01:38.749 INFO  c.k.k.c.keyword.builtin.CommentKeyword   - Element is successfully found: TestObject - 'Object Repository/CSM_Process_Incoming_Simona/Page_Migration - Migration - Oracle Applications/input_Config_Set_Choose File'
2020-04-15 11:01:38.751 DEBUG testcase.CSM_Process_Incoming_Simona     - 2: click(tObj)

This proves that your XPath selector is correct. Your code successfully found the <input> element.

But when the script clicked the element, An Exception was raised with message “invalid argument”.

The MDN document about “Invalid Argument” is found at https://developer.mozilla.org/en-US/docs/Web/WebDriver/Errors/InvalidArgument

I do not see the reason why “Invalid Argument”.

Therefore I would like to see how the test goes with Firefox.

If your test runs successfully using Firefox, it proves that your test script is OK. There could be a hidden problem somewhere in Chrome + Chrome Driver.

If it fails using Firefox as well, in your target page (https://ehgw-dev1.login.us6.oraclecloud.com) may live a Monster that prevents you from enjoying E2E testing.

Anyway, let’s do experiments first.

Caused by: org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed.

You haven’t installed Firefox browser into your Windows 10 PC. You can get the installer from here:

It is already installed, am I missing something?

Where did you installed the firefox.exe? Could you copy & paste the path?

C:\Users\simona_bara\AppData\Local\Mozilla Firefox

I don’t have much knowledge on using DevTools, thanks for the tip :slight_smile:

Right, so that is telling us the element identified by that selector does not actually exist. I got that selector from you:

image

All we did was fix it up to work in the DevTools console. But Chrome is saying the element it identifies doesn’t exist - did you make sure the element was present on the page?

I hate race conditions - I’ll back off until @kazurayam is done.

On my PC, I have Firefox at
C:\Program Files\Mozilla Firefox\firefox.exe
and I can run my test with Firefox successfully.

How come you have Firefox installed at %USERPROFILE%\AppData\Local\Mozilla Firefox. …

By the way, the following doc describes how Gecko Driver searches for the binary of Firefox browser:


@simona.bara

Can you just tentatively copy the Mozilla Firefox folder under C:\Program Files? and try running your test.

I need admin rights to copy the Mozilla Firefox elsewhere, I’m using my company laptop. When installing it I was also required admin rights, but hit cancel and got installed anyways (probably not properly).
I will raise IT ticket for an admin to help me with credentials and come back here with the test result.

As this document describes

the GeckoDriver look into the Windows REGISTRY

HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\ *[VERSION]* \Main\PathToExe

to find out the location of firefox.exe as default.

@simona.bara

Can you use regedit.exe and see what value you have for that registry key?

If the registry key is not pointing the correct location of firefox.exe, you can edit it.

Hi kazurayam,
Was able to properly install Firefox now and execute the test, here’s the result: FirefoxOutput.txt (17.5 KB)
Katalon still couldn’t click Choose File (Firefox showing “Browse”).

Sorry forgot to include your debug printing: FirefoxOutputUpdated.txt (18.2 KB)

Thank you for updates.

FirefoxOutput.txt contained an interesting message:

Caused by: org.openqa.selenium.InvalidArgumentException: 
    Cannot click <input type=file> elements

I googled with this message as key. I found an issue in StackOverflow.

The W3C WebDriver Specification, in its description of the Element Click algorithm in Section 14.1, step 3 states: “If the element is an input element in the file upload state1 return error with error code invalid argument.”

When the Chromium team completes spec-compliance for chromedriver, it will behave as geckodriver, IEDriverServer.exe, the current preview version of Microsoft’s driver implementation for Edge, and Apple’s just released driver implementation for Safari 12 all behave.

To successfully upload files using WebDriver, you should use the sendKeys method with the full path to the file you want to upload.

The above post tells us that any Selenium-base test script can not click the <input type="file"> element at all. That’s a correct behaviour as the W3C Specification defines.

Wow, here comes a Monster! I have never seen it. But I can guess a reason why.

If a browser opens a FileChooser dialogue when I click the <input type="file"> element using WebDriver, then how can I continue interacting with the dialog? — Nothing I can do. I can not interact with the OS-built-in FileChoose dialogue with WebDriver (=Katalon Studio) at all. Therefore I do not want the dialogue to open. Rather I want to send a file path to upload, and immediately go ahead.

It was a good learning. Thank you.

Thanks, kazurayam. After finding the mechanism behind the Monster doesn’t seem so scary anymore, hehe!
Therefore my only option would be using Upload File keyword with input on the full path of file I want to upload, am I correct?

Possibly you want this: