By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,767 Members | 1,987 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,767 IT Pros & Developers. It's quick & easy.

automate testing a website/page

P: 13
hello,

I am trying to open up a webpage, say "http://gmail.com", enter username, passwd, click on submit button and do loads of other things - ALL THROUGH AUTOMATION, writing a script in python.

I tried my hands at cPAMIE but facing prbs regading the ids of the gui elements i.e. the places where id of a particular gui element is not mentioned in the htm source file, we cannot use the cPAMIE methods.

I am trying my hands at win32com.client now, but being a newbie i am not able to proceed satisfactorily.

Could anyone guide me the way to accomplish my job i.e suggesst any other module to automate browser, or point me to some informative tutorials.

ANYONE WHO HAS DONE SUCH STUFF BEFORE, can u help me please?

Regards,
rdps
Nov 10 '06 #1
Share this Question
Share on Google+
10 Replies


P: 13
Adding further to my query, how to identify the elements on the web page which do not have any id mentioned in the html text ?
Nov 10 '06 #2

P: 38
Here is a solution for the problem when you actually know the names of your web components. Notice the ie.ReadyState instead of the fixed sleep. I will be back soon with a solution that uses component index instead. If you are to do automatic tests on a web soluition I would strongly recommend that you push the development team to use names or ids on their components. You can do a much better regression test if names are used. The order of the components might change. Names and ids can also change, but they are usually more lasting.

Expand|Select|Wrap|Line Numbers
  1. from win32com.client import *
  2. import time
  3. ie = Dispatch('InternetExplorer.Application')
  4. ie.Visible = 1
  5. ie.Navigate('www.thescripts.com')
  6. while(ie.ReadyState != 4):
  7.     time.sleep(0.1)
  8. page = ie.Document
  9. textBox = page.getElementById('q')
  10. textBox.value = 'pamie'
  11. searchButton = page.getElementById('sa')
  12. searchButton.click()
Best regards
/Fredrik
Nov 10 '06 #3

bartonc
Expert 5K+
P: 6,596
Thanks Fredrik! Members of this forum are gaining a lot of knowledge from your posts and so am I. I really appreciate the you for sticking around. BTW, have you noticed that searches don't work very well in bring up current posts? Thanks, again,
Barton

Here is a solution for the problem when you actually know the names of your web components. Notice the ie.ReadyState instead of the fixed sleep. I will be back soon with a solution that uses component index instead. If you are to do automatic tests on a web soluition I would strongly recommend that you push the development team to use names or ids on their components. You can do a much better regression test if names are used. The order of the components might change. Names and ids can also change, but they are usually more lasting.

Expand|Select|Wrap|Line Numbers
  1. from win32com.client import *
  2. import time
  3. ie = Dispatch('InternetExplorer.Application')
  4. ie.Visible = 1
  5. ie.Navigate('www.thescripts.com')
  6. while(ie.ReadyState != 4):
  7. time.sleep(0.1)
  8. page = ie.Document
  9. textBox = page.getElementById('q')
  10. textBox.value = 'pamie'
  11. searchButton = page.getElementById('sa')
  12. searchButton.click()
Best regards
/Fredrik
Nov 10 '06 #4

P: 13
Thnaks a lott fredrick. U have been very helpful.

Just wanted to know from where to get the list of attributes/methods for an object ? Say, u call page.getElementId(), how are u arriving at the .method? I am using an IDE which doesnt support auto completion. I am getting stuck with the methods which are available for a particular object.
Nov 10 '06 #5

P: 38
Here is the same solution using index. I use index of all components. You can use links for example to first sort on links (look at my other posts).

Expand|Select|Wrap|Line Numbers
  1. from win32com.client import *
  2. import time
  3. ie = Dispatch('InternetExplorer.Application')
  4. ie.Visible = 1
  5. ie.Navigate('www.thescripts.com')
  6. while(ie.ReadyState != 4):
  7.     time.sleep(0.1)
  8. page = ie.Document
  9. page.all.item(557).value = 'pamie'
  10. page.all.item(559).click()
I use PythonWin which can has auto completion. I guess you can find information about Internet Explorer COM function calls on Microsofts web page. I haven't really looked, I just use auto completion. PythonWin is free. It is fast and easy to use. It doesn't support building projects like commercial tools like Wing IDE though.

BR
/Fredrik
Nov 10 '06 #6

P: 38
By the way, have you tried functions like textAreasGet() in Pamie? I have only looked at the documentation. If you enter an empty filter it might return a list of all of your text areas.
Nov 10 '06 #7

P: 38
One more thing... Read this article

http://agiletesting.blogspot.com/200...on-part-1.html

The MaxQ tool seems pretty cool. It will let you record web gui operations and generates a Jython script of all http requests.

OK, maybe it doesn't quite qualify for a system test, but on the other hand tools like Pamie and using COM for IE will only test the system with the IE browser.

/Fredrik
Nov 10 '06 #8

P: 13
Pamie mehtod : textAreaGet (name) takes an argement which is: The name, id or index of the textarea. But, i dont have any such id, which is the unfortunate thing.
Nov 10 '06 #9

P: 38
No, look at the documentation. There are several different functions that return a list of components based on a filter. textBoxesGet(), textAreasGet(), tablesGet(), and radioButtonsGet() are some examples. I don't know how they define [filter], but if you can use an empty filter you should be able to get all components of one type.

/Fredrik
Nov 10 '06 #10

P: 38
Ok. I have looked at the code for PAMIE. All the functions above can be called without parameters. The default value of filter is None. They will return a list of components of the specified type.
Nov 10 '06 #11

Post your reply

Sign in to post your reply or Sign up for a free account.