Bo Milanovich
Bo Milanovich

Reputation: 8203

How to click a submit button in QWebView?

I have the following code (excluded class constructor etc) - I am using PySide btw:

self.view = QWebView()

frame = self.view.page().mainFrame()
document = frame.documentElement()
search = document.findFirst("input[name=q]")
search.setAttribute("value", "srbija")

button = document.findFirst("input[name=btnK]")

As you may have noticed, this is straight from google.com homepage. I am trying to basically search the page. But I can't figure out click the "Google Search" button. The documentation only mentions the button.evaluateJavaScript("click()"), but this only calls the JS method - I don't need any JS methods in this case, I need to actually click the button.

Upvotes: 2

Views: 4015

Answers (1)

In order to close this so it does not look unanswered... :)

Try replacing click() with this.click(), as per this question:

How to follow a link in QWebKit?

Upvotes: 5

Related Questions