Jump to content

My new user challenge.


marsol
 Share

Recommended Posts

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

Link to comment
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

Link to comment
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 ]---
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...