PDA

View Full Version : How to choose value from (html) option list using WebKit



SuperSergey
24th November 2012, 15:33
I know this is a C++ forum, and i'm doing this in python, so if you can at least give me a general idea on how you do this, would be great.
I'm trying to auto select birthday from option list on the website, by using PyQt4.QtWebKit but having trouble doing this.

When I want to select radio button I do this:


doc = QWebView.page().mainFrame.documentElement()
g = doc.findFirst("input[id=gender]")
g.setAttribute("checked", "true")

Some text input:


doc = QWebView.page().mainFrame.documentElement()
s = doc.findFirst("input[id=say_something]")
s.setAttribute("value", "Say Hello To My Little Friends")

But How to select month from option list?


<select tabindex="11" name="birthday_m">
<option value="">---</option>
<option value="1">JAN</option>
<option value="2">FEB</option>
<option value="3">MAR</option>

ChrisW67
26th November 2012, 23:02
This is a Qt forum, not exclusively C++, but there is not a lot of PyQt traffic.

At a guess:


doc = QWebView.page().mainFrame.documentElement()
s = doc.findFirst("select[id=birthday_m]")
s.setAttribute("value", "2")