filling web forms using QWebElements

403 views Asked by At

i wanted to fill the first form on yahoo registration(https://edit.yahoo.com/registration?) automatically . first of all let me assure you this is for practicing with Qt Webkit only and only . no harm to yahoo or anyone else is meant by me and no harmful software will be produced . that being said ... i know how to fill normal web forms by setting the "value" attribute to "sth" but some of yahoo's fields are not normal . whats written inside them has nothing to do with the "value" attribute . i asked someone and was told the value is changed by js somehow . to be exact im talking about first and second name and birth year and day fields . so my first question is : how can i change those input fields . someone said i could evaluate javaScript which i barely know :)

frame->findFirstElement("#firstname").setAttribute("value","asghar");

my second question is about the birth month and gender and country selects . to change them i changed the element attribute "selected" to "selected" but it didnt work . when i open the select i can see my desired option is already highlighted but not actually selected . how can i select that option ?

frame->findFirstElement("#mm > option:nth-child(8)").setAttribute("selected","selected");

with many thanks in advance.

1

There are 1 answers

0
A73rnA On

i solved my problem. i dont know exactly why but the Qt way didnt work . i had to evaluate JS for the entire webform . each time getting an element by id and setting its value . it worked for me that way