1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How would I automate this?

Discussion in 'General Programming Chat' started by redmoon, May 28, 2011.

Tags:
  1. redmoon

    redmoon Regular Member

    Joined:
    Aug 19, 2009
    Messages:
    245
    Likes Received:
    73
    Is there any way to automate this code to submit votes like it was done with a mouse click? I'm thinking it could be done with php but I have no idea how to code it. Appreciate any help.

    Code:
    <input class="submit yes" type="submit" onclick="submitVote(XXXX, XXXX, 'Y')" value="Yes" name="vote">
     
  2. xboxps3wow

    xboxps3wow Power Member

    Joined:
    Jan 15, 2010
    Messages:
    737
    Likes Received:
    239
    Occupation:
    student
    Location:
    Chicago
    imacros...
     
  3. om39a

    om39a Regular Member

    Joined:
    May 29, 2011
    Messages:
    212
    Likes Received:
    67
    Location:
    BHW
    You can go for simple Ruby scripts with watir.

    Code:
       require 'watir'   # the watir controller
    
       # set a variable
       test_site = 'yoursite web site'
      
       # open the IE browser
       ie = Watir::IE.new
    
       
       ie.goto(test_site)
    
      #For signing into ur site
       
        $ie.text_field(:name, "Email").set("YourEmail")
        $ie.text_field(:name, "Passwd").set("password")
        $ie.button(:value, "Sign in").click
    
       #clicking on the vote button 
    
       $ie.button(:value, "Yes").click
    PM me if You need some clarifications
     
  4. madblacker

    madblacker Regular Member

    Joined:
    Nov 2, 2009
    Messages:
    268
    Likes Received:
    19
    Look up a tool called selenium its a website testing software with an API for all major programming languages, its really cool and one of the best for programatically building bots since it controls a real browser
     
  5. Baybo.it

    Baybo.it Registered Member

    Joined:
    Aug 9, 2011
    Messages:
    72
    Likes Received:
    39
    Occupation:
    Founder of Baybo.it
    Location:
    San Francisco
    Home Page:
    Do you have any experience with JavaScript or JQuery? You can do a form.submit style form submission within a callback function if you had a form you wanted submitted in your html. Since javascript is a client side language, this is probably the easiest way to accomplish what you're trying to do. Rubyscript, as suggested above, may be an acceptable alternative. Not a fan of ruby, myself, so I don't have much experience with that option.

    If you would like code samples for reference, just let me know.