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()
    self._page.mainFrame().setScrollPosition(el_pos)
    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":https://sec.yimg.com/i/us/str/gr/comgrchsfledlg.gif 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":http://qt-project.org/doc/qt-4.8/qwebpage.html#Extension-enum


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.