Sign in to follow this  
Followers 0
marsol

My new user challenge.

6 posts in this topic

What started as a simple project has turned into a personal challenge for me.

My task is to automate the submission of data to a webpage form. This is the page. http://www.carnival.com/BonVoyage/AddToCart.aspx?pid=745

My purpose for doing this is that it is possible to find out cabin assignments by entering your booking number and then cycling through different stateroom numbers until you find the right one. For whatever reason the cruise line doesn't disclose cabin assignments until a couple weeks before sailing even theugh they are assigned. Many people use this technique to find out their cabin assigment in advance. With hundreds of staterooms on a ship doing it manually can take a long time.

I was able to make a rather crude script using another macro program. However, it had some limitations I didn't like. The main one was that there was no way to determine if the webpage had reloaded completely to see if it was the right booking number/stateroom combination. The only thing I could do was to wait a specified number of seconds and hope the page was done reloading. This is inefficient and not very elegant. It also makes it difficult to write a script to cover different internet connection speeds and conditions. I'm hoping the IELoadWait function of Autoit can accomplish this.

I would like to make a script that is screen resolution, browser version and connection speed independent. While it may be sacreligious to some, I don't necessarily need to support different browsers, IE would suffice for my purposes.

Besides being a complete beginner using AutoIT, I don't know javascript, html and probably a few other things to be competent to accomplish what I want. But hey, that never stopped me from trying before. About 1000 years ago my education was in programming. I didn't end up in the field though and I often wish I did. If you happen to have any casino questions feel free to ask, I'd be happy to share any insight I have.

So here's my first problem.

I need to insure that I select the right stateroom number text input field prior to entering a room number. Easy to do, but not independent by using the mouseclick function. Tabbing to the field doesn't seem solid either as different browser configurations may have a different number of tabs to get the desired field. Any suggestions?

I'm not looking for someone to do this for me, only point me in the right direction.

Mark

Share this post


Link to post
Share on other sites



Though I don't fully understand what you're trying to do. I assume you're looking for the fact that the two numbers match. You have one number and you don't have the other. My suggestion might be to use a fixed position for entering each number and then clicking submit. Wait a decent ammount of time and then check for the red pixels in the text "Invalid Booking and/or blah blah"

They should be in the same place every time or atleast relatively close. If they aren't perfect each time you can loop through the pixels from a certain point to a certain point (in a rectangle shape) until you find the red. If you don't find the red then have the script stop and popup a window saying the values it entered. The pixel loop would be two loops inside of eachother. One moving the y direction forward until it reaches the end of your box while the second loop increments the x position every time the y direction gets to its end.

Ophidian

Share this post


Link to post
Share on other sites

Here is quick example using the IE.au3 library:

#include <IE.au3>

; Create new browser and load the webpage
$oIE = _IECreate ('http://www.carnival.com/BonVoyage/AddToCart.aspx?pid=745')

; wait until webpage has loaded
_IELoadWait ($oIE)

; Create a variable to store the form
$oForm = _IEFormGetObjByName ($oIE, "addToCartSearchResults")

; Set the value of the booking no and Stateroom no
$oText = _IEFormElementGetObjByName ($oForm, "AddToCart1:bookingNumber")
_IEFormElementSetValue ($oText, "111")
$oText = _IEFormElementGetObjByName ($oForm, "AddToCart1:cabinNumber")
_IEFormElementSetValue ($oText, "111")

; Submit the form
_IEFormImageClick ($oIE, "AddToCart1:btnSubmit", "name")

; wait until webpage has loaded
_IELoadWait ($oIE)

; get html from page and check if 'Invalid Booking and/or Cabin Number' text is found
$sHTML = _IEDocReadHTML ($oIE)
If StringInStr($sHTML,'Invalid Booking and/or Cabin Number') Then
 MsgBox(0,'','Found')
Else
 MsgBox(0,'','NOT Found')
EndIf

Using the above in a loop I'm sure you can get the necessary info you require.

Try it and see. If you need more help, just ask.


----[ SandyD ]---

Share this post


Link to post
Share on other sites

Thank you both. Sandy, that is very much what I was looking for. I'm sure that will get me what I want.

Mark

Share this post


Link to post
Share on other sites

God Im sooo used to using a recognition method of doing everything. (Video game scripting and such) ...

AutoIt has such nice tools for beating IE into the floor and making it it's bitch.

Its beautiful.. It really is..

Share this post


Link to post
Share on other sites

AutoIt has such nice tools for beating IE into the floor and making it it's bitch.

Its beautiful.. It really is..

AHAHAHAH! Omg, that's going into my sig.

$i_Points -= 1

$sz_Reason = "Jacking OP's thread"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0