Important: Please read the Qt Code of Conduct -

Bug? Choose file dialog sometimes opens instead of QWebPage.chooseFile call

  • I emulate clicking file upload button with events, to automate this action. Code of mouse click:

    @# el - upload button
    el_pos = el.geometry().center()
    scr_pos = self._page.mainFrame().scrollPosition()
    point_to_click = el_pos - scr_pos

    press = QMouseEvent(QMouseEvent.MouseButtonPress, point_to_click, Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
    release = QMouseEvent(QMouseEvent.MouseButtonRelease, point_to_click, Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
    QApplication.postEvent(self._handler, press)
    QApplication.postEvent(self._handler, release)@

    Then I handle file choosing with QWebPage.chooseFile function, and in very trivial cases it works as expected. But on many sites after mouse click "system choose file dialog": opens (even if QWebView is hidden).

    Is it a bug? Is there more correct way to automate file upload button handling?

    I'm using PyQt5.2.1, Windows 7 x86

  • That's not bug. Answer to this question - "QWebPage::ChooseMultipleFilesExtension":

Log in to reply