QWebKit classes use CSS2 selector syntax to search for elements.
So, the required parameter can be found as follows:
doc = webview.page().mainFrame().documentElement() option = doc.findFirst('select[name="birthday_m"] > option[value="3"]')
and then the selected attribute can be set in the option element as follows:
option.setAttribute('selected', 'true')
However, for some reason, this does not immediately refresh the page (and does not call the webview.reload() call).
So, if you need an immediate update, the select element might be the best way:
doc = webview.page().mainFrame().documentElement() select = doc.findFirst('select[name="birthday_m"]')
and then set the selected parameter as follows:
select.evaluateJavaScript('this.selectedIndex = 3')
source share