nzsquall
nzsquall

Reputation: 405

not handling the file upload window well

I have a page object called import_transaction_file.rb, which one of the method click_choose_file will invoke a standard file upload windows show below:

the code for the page object is:

class ImportTransactionFile
  include PageObject
  ....
  button(:choose_file, :id => 'createBulkPayment:file')
  ....
  def click_choose_file
    choose_file
  end

end

In my test program below:

....
def test_go_to_direct_credit_payment_page
    ...
    @import_transaction.click_choose_file

 #   @browser.window(:title => 'File Upload').use do
 #     @browser.button(:name => 'Cancel').click
 #   end
 # doesn't work
  end

the method click_choose_file in the test program will invoke the standard file upload window as attached below: enter image description here

How do I:

Will you recommend me to do it in the page-object or the test program?

Thanks for your reply.

Upvotes: 1

Views: 687

Answers (1)

CustomNet
CustomNet

Reputation: 652

I have a very similar thing to what you're asking and mine works using:

browser.file_field(:text, "File Upload").set("C:\path\to\file\to\upload")

Hope that helps!

Upvotes: 1

Related Questions