Thank you Jeroen that makes a lot of sense.
I really like the API, it's very powerful and intuitive.
-----Original Message-----
From: watin-users-bounces@...
[mailto:watin-users-bounces@...] On Behalf Of Jeroen
van Menen
Sent: Monday, January 29, 2007 1:22 PM
To: watin-users@...
Subject: Re: [Watin-users] Not sure how to proceed
Alan,
The HTML is help full and your explaination about having a cell in a row
you can identify will also help. So I have two suggestions:
<a href=3D"customerOrders_list.aspx?id=3D14566" =
target=3D"_self">View</a>
1. I assume your datagrid shows orders. Each order having their own
orderid. Is that the id which I see in the HTML, in this case 14566 and
"do you know" the orderid by forhand/when doing the test. If so, you
could use this:
ie.Link(Find.ByUrl(new Regex("14566"))).Click();
2. Using the know text "DC APAC" in a tablecell in the same tablerow.
For this example I assume the following (a bit simplified) tablerow
layout. =20
<TR><TD>DC APAC</TD><TD>some other tablecell</TD><TD><A>the link to
click on</A></TD><TR>
// First I'm going to find the tablecell with the know text. Then I cast
its parent (property) to ElementsContainer, assuming it returns the
tablerow.
ElementsContainer tablerow =3D
(ElementsContainer)ie.Table("yourtableid").TableCell(Find.ByText("DC
APAC")).Parent;
// I know that the third tablecell in that tablerow contains the (one)
link I want to click on so:
tablerow.TableCells[2].Links[0].Click();
That's it. Hope this gets you going.
Jeroen
BTW. Since this question has been asked severall times before, I think
adding ParentTableRow and ParentTable properties to TableCell will help.
I'll add a feature request for this.
> Datum: 29/01/07 05:56 PM
> Van: "Alan Wolfe"=20
> Aan: watin-users@...
> CC:=20
> Onderwerp : Re: [Watin-users] Not sure how to proceed
>=20
>=20
Hmm do you mean you can make WatiN click a link that doesn't have an ID?
=20
The link itself in the rendered HTML looks like this:
=20
View
=20
There are a lot of other links in the table that have "View" as their
text.
=20
One thing though is that this link is in a table row which a couple 's
earlier than this view link has some text unique to the row I'm looking
for that is "DC APAC ".
=20
Is there a way to click the link with any of that information?
=20
From: watin-users-bounces@...
[mailto:watin-users-bounces@...] On Behalf Of William
Yeung
> Sent: Monday, January 29, 2007 8:47 AM
> To: watin-users@...
> Subject: Re: [Watin-users] Not sure how to proceed
=20
If you dont have too much datagrid or the id prefix is distinguishable,
use regex parameter will do.
On 1/30/07, Alan Wolfe < awolfe@...> wrote:
> Right, I was just mistakenly assuming everyone here was programming
their pages in asp.net since WatiN itself is a .net lib but that was an
incorrect assumption.
> =20
> Gotta love MS...unfortunately there's no way to give an ID to the link
using a datagrid.
> =20
> Thanks anyways
> =20
> From: watin-users-bounces@...
[mailto:watin-users-bounces@...] On Behalf Of Jeroen
van Menen
> Sent: Saturday, January 27, 2007 2:22 AM
> To: watin-users@...
> Subject: Re: [Watin-users] Not sure how to proceed
> =20
> Alan,
> WatiN isn't aware of any technique that is used to create a webpage
(asp, ruby on rails, Lotus Notes webpages, plain old html created in
frontpage or notepad). It looks at the html that is send to and renderd
by the webbrowser (Internet Explorer) by exploring the DOM object model
of a webpage. The way the html is created for a datagrid by the asp.net
framework (in your situation) is indeed specific to asp. But again the
result is a html page send to the browser. You can explore this html by
using the IE Developer Toolbar from Microsoft
http://www.microsoft.com/downloads/details.aspx?FamilyID=3De59c3964-672d-=
4
511-bb3e-2d5e1db91038&displaylang=3Den. The getting started article on =
the
Watin website (http://watin.sourceforge.net/gettingstarted.html ) shows
how you can use it to explorer and automate your webpage.
> If you send in (a part of) the html I will show you how to automate
your datagrid.
> Hope this info helps to beter understand how WatiN works,
> Jeroen
>=20
>=20
>=20
>=20
>=20
> =20
> > Datum: 27/01/07 12:33 AM
> > Van: "Alan Wolfe"=20
> > Aan: watin-users@...
> > CC:=20
> > Onderwerp : Re: [Watin-users] Not sure how to proceed
> >=20
> >=20
> Sorry I forgot to mention this is an asp.net datagrid with a hyperlink
column inside. MS overcomplicates things...I guess this is an asp.net
issue so I'll ask that on the appropriate forums.
> =20
> Thanks for the info regarding when to fail a test. I wasn't sure if
there was some kind of standard best practice or something.
> =20
> Thanks a bunch!
> =20
> From: watin-users-bounces@...
[mailto:watin-users-bounces@...] On Behalf Of Jeroen
van Menen
> > Sent: Friday, January 26, 2007 3:29 PM
> > To: watin-users@...
> > Subject: Re: [Watin-users] Not sure how to proceed
> =20
> > Hi Alan,
> > To be able to answer your question regarding the datagrid, could you
supply a bit of HTML?
> > Regarding your question about when to fail a test. Most of the times
you know what you expect when you hit a button. When it redirects you to
a new page you might want to check ie.Url or you can check some page
title or maybe there is some result on the next page you need to check.
Jeroen
> >=20
> >=20
> >=20
> >=20
> > Datum: 26/01/07 10:14 PM
> > > Van: "Alan Wolfe"=20
> > > Aan: watin-users@...
> > > CC:=20
> > > Onderwerp : [Watin-users] Not sure how to proceed
> > >=20
> > >=20
> Hey guys,
> =20
> I'm a noob here and I had a couple questions.
> =20
> If I have a datagrid in an aspx file that has a hyperlink column and I
want WatiN to click on one of those hyperlink columns speicifically, how
can I do that?
> =20
> I don't seem to be able to give the hyperlinkcolumn an ID for each one
otherwise I could just do that.
> =20
> Does anyone know?
> =20
> Also I was wondering what is a good way to know a test has failed or
not? Do people just generally check for certain elements on the page
after a button has been clicked etc or is there a way that makes more
sense?
> =20
> Thanks!
> Alan
> >
> > > [ (geen bestandsnaam) (0.3 Kb) ]
> > > [ (geen bestandsnaam) (0.2 Kb) ]
> >
> > [ (geen bestandsnaam) (0.3 Kb) ]
> > [ (geen bestandsnaam) (0.2 Kb) ]
>
------------------------------------------------------------------------
-
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to
share your=20
> opinions on IT & business topics through brief surveys - and earn cash
>
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D=
DEVDE
V
>=20
> _______________________________________________
> Watin-users mailing list
> Watin-users@...
> https://lists.sourceforge.net/lists/listinfo/watin-users=20
>=20
>=20
=20
>
> [ (geen bestandsnaam) (0.3 Kb) ]
> [ (geen bestandsnaam) (0.2 Kb) ]
------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D=
DEVDE
V
_______________________________________________
Watin-users mailing list
Watin-users@...
https://lists.sourceforge.net/lists/listinfo/watin-users
|