0

I am trying to test a fileupload via browser in selenium.

Setup is : Eclipse on Mac, Selenium in Bamboo on Linux, Java, Chrome

On my website the file upload works with a button . This button opens native browser file upload dialog(without a input; the button calls a JS on ng-click).

<button class="cs-button-link-01" ng-click="uploadFile()" ng-if="context.permissions.edit">
    <i class="cs-icon cs-icon-circle-plus cs-iconsize-200"></i>&nbsp;
    <span cs-translate="'csAssetFileListWidget.AddFileBtn'">File</span>
</button>

So the fileupload works fine for mac and linux on my mac with using a robot class like in File Upload using Selenium WebDriver and Java Robot Class for linux it works well with:

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.delay( 1000 * 4 );
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

But now I have the problem that I want to run it on Bamboo (on Linux, headless). (AutoIt cannot work cause its 4 Windows)

Do you have any ideas how to solve this problem?

gotama
  • 1
  • 1

1 Answers1

0

there should be an input element somewhere below or at the end of body. He will accept the file which is being select from native 'select file' window, which is different for each OS.

If you send the path of file to this input will trigger the input. Example:

<input type="text" id="drive_hist_state" name="drive_hist_state" style="display:none;">


WebElement input = driver.findElement(By.id("drive_hist_state"));
input.sendKeys("/path/to/file/test.txt");
Infern0
  • 2,565
  • 1
  • 8
  • 21
  • Yes this is the problem that i have no input. Just a button with a ng-click="uploadFile()" wich triggers a JS – gotama Apr 24 '20 at 13:51
  • when you click it, it opens default OS 'select file' window or it renders some kind of form in website.. can you give more details and link if possible. – Infern0 Apr 24 '20 at 13:55
  • thanks 4 your comment. Yes it opens the default OS select file. A link i cannot give cause its an internal application. – gotama Apr 24 '20 at 14:39