YusukeIwaki / playwright-ruby-client

Playwright client for Ruby
https://playwright-ruby-client.vercel.app/
MIT License
336 stars 34 forks source link

Clicking on elements that trigger file choosers consecutively cause the process to hang. #231

Closed KonnorRogers closed 1 year ago

KonnorRogers commented 1 year ago

Step To Reproduce / Observed behavior

1.) Click button that opens file chooser, select file, click another button that opens file chooser, process hangs.

https://github.com/KonnorRogers/ash-editor/blob/547927784e72990d0a1b0879c062ad3318bef94e/tests/rails/test/system/attachments/attachment_attributes_test.rb#L41-L65

^ Theres an extra "click bold button to fix file chooser" in here.

Expected behavior

It should be expected you choose a file, click another button, open file chooser, choose another button without issue.

Environment

Paste the output of ruby --version

Ruby 3.1.2 Rails 7.0.4 Playwright 1.27.1

Repo: https://github.com/KonnorRogers/ash-editor (need to remove an extra click)

Im not sure if the issue lies with the Playwright-Ruby-Client or with Playwright itself.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

KonnorRogers commented 1 year ago

Bump.

YusukeIwaki commented 1 year ago

Hi, sorry for late response.

I tried the code below (input 2 files with 2 threads) however it worked without hang.

  it 'https://github.com/YusukeIwaki/playwright-ruby-client/issues/231' do
    with_page do |page|
      page.content = <<~HTML
      <input type="file" name="file1" />
      <input type="file" name="file2" />
      HTML

      choosers = Concurrent::Promises.zip(
        Concurrent::Promises.future {
          page.expect_file_chooser do
            sleep 1
            page.click('input[name="file1"]')
          end
        },
        Concurrent::Promises.future {
          page.expect_file_chooser do
            sleep 1
            page.click('input[name="file2"]')
          end
        },
      ).value!

      choosers.each do |chooser|
        chooser.set_files(__FILE__)
      end
    end
  end

@KonnorRogers Could you provide the execution log with DEBUG=1 ?

DEBUG=1 bundle exec rspec ...
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.