473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

automate testing a website/page

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
10 3816
rdps
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
fuffens
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
6,596 Expert 4TB
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
rdps
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
fuffens
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
fuffens
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
fuffens
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
rdps
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
fuffens
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
fuffens
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

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

Similar topics

1
by: Niko | last post by:
Hello, I want to retrieve the details of an SSL certificate of HTTPS websites, using openSSL, running on Windows 2003. This works fine as follows: openssl s_client www.somewebsite.com:443 >...
2
by: Kate Gibbs | last post by:
I need to write a simple utility in VB.NET that reads an Excel file, gets some data from a sheet, then...it needs to automate internet explorer in a robot manner. I know that Application Centre...
0
by: Lumpierbritches | last post by:
Option Compare Database Option Explicit '************ Code Start ********** 'This code was originally written by Dev Ashish. 'It is not to be altered or distributed, 'except as part of an...
4
by: Chris via AccessMonster.com | last post by:
I have the challenge of needing to automate table creation. It doesn't end there the tables have to be created from one table that looks something like this... Email ...
4
by: mparisi | last post by:
I have a responsibility within my testing department to automate the submission of data on 4 sequential asp pages. Here's the tasks: 1. Sign in 2. Enter form data and submit 3. Enter more...
1
by: mmtkspec159 | last post by:
Hello, pretty basic issue.. how do I open a website, paste text into a textbox on the page, and click a button on the page from a VB.NET app? (code example please!) thanks!
3
by: Alexnb | last post by:
Okay, I already made this post, but it kinda got lost. So anyway I need to figure out how to test if the user is able to connect to a specific website. Last time I got pointed to the urllib2 page,...
0
by: Alexnb | last post by:
Timothy Grant wrote: well I can tel you it didn't work for me. In fact I didn't see the code you posted on there, I ended up figuring it out on my own with a little help from the missing manual...
21
by: =?ISO-8859-1?Q?Fad=A5?= | last post by:
Hello guys, I want to do kinda of an A/B split testing on a website I run. I just created a new version but I need to keep both version running and see which one will perform better. First, I'm...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.