Results 1 to 2 of 2

Thread: How to choose value from (html) option list using WebKit

  1. #1
    Join Date
    Nov 2012
    Posts
    1
    Qt products
    Platforms
    Unix/X11

    Default How to choose value from (html) option list using WebKit

    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:

    Qt Code:
    1. doc = QWebView.page().mainFrame.documentElement()
    2. g = doc.findFirst("input[id=gender]")
    3. g.setAttribute("checked", "true")
    To copy to clipboard, switch view to plain text mode 

    Some text input:

    Qt Code:
    1. doc = QWebView.page().mainFrame.documentElement()
    2. s = doc.findFirst("input[id=say_something]")
    3. s.setAttribute("value", "Say Hello To My Little Friends")
    To copy to clipboard, switch view to plain text mode 

    But How to select month from option list?

    Qt Code:
    1. <select tabindex="11" name="birthday_m">
    2. <option value="">---</option>
    3. <option value="1">JAN</option>
    4. <option value="2">FEB</option>
    5. <option value="3">MAR</option>
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to choose value from (html) option list using WebKit

    This is a Qt forum, not exclusively C++, but there is not a lot of PyQt traffic.

    At a guess:
    Qt Code:
    1. doc = QWebView.page().mainFrame.documentElement()
    2. s = doc.findFirst("select[id=birthday_m]")
    3. s.setAttribute("value", "2")
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qt webkit segmentation fault with pluginEnabled option
    By victor in forum Qt Programming
    Replies: 2
    Last Post: 27th June 2012, 15:33
  2. Replies: 3
    Last Post: 1st April 2011, 15:02
  3. Webkit: extract information from HTML
    By bunjee in forum Qt Programming
    Replies: 7
    Last Post: 1st January 2011, 20:50
  4. get html tag by clicking (webkit)
    By billconan in forum Qt Programming
    Replies: 0
    Last Post: 23rd June 2009, 23:07
  5. Qt 4.4 WebKit: WYSIWYG HTML editor?
    By 24pm in forum Qt Programming
    Replies: 6
    Last Post: 13th March 2009, 11:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.