How to click links like these - <a href="template.do?actionToCall=viewList&select=true">text link</a>

19 views
Skip to first unread message

jerald

unread,
Dec 16, 2009, 6:43:29 AM12/16/09
to watij
Dear friends,

I have a doubt on how to find and click the link with "?" and "&". I
think it can be done. But i tried with no luck.

please consider this -

<a href="template.do?actionToCall=viewList&select=true">text link</a>

this is my code -

ie.link(url,"/template.do?
actionToCall=viewList&selectConf=true/").click();

This is not working and the link is not clicked.

Regards
Jerald

Darrell Grainger

unread,
Dec 16, 2009, 10:51:51 AM12/16/09
to wa...@googlegroups.com
Why do you have the trailing / on the url? Your code is looking for
"/template.do?actionToCall=viewList&selectConf=true/" but the url
should be "/template.do?actionToCall=viewList&selectConf=true".

2009/12/16 jerald <paulj...@gmail.com>:
> --
>
> You received this message because you are subscribed to the Google Groups "watij" group.
> To post to this group, send email to wa...@googlegroups.com.
> To unsubscribe from this group, send email to watij+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/watij?hl=en.
>
>
>

Jerald paul

unread,
Dec 17, 2009, 12:29:33 AM12/17/09
to wa...@googlegroups.com
Hi Darrell,

First i say thanks for your reply.

i have link which says - <a href="/configAction.do?actionToCall=initSingleConfig&amp;configName=ALERTS&amp;ascending=false&amp;configType=User">Alerts </a>

I tried with this -

ie.link(url, "/configAction.do?actionToCall=initSingleConfig&configName=ALERTS&ascending=false&amp;configType=User").click();


but unfortunately this did not work for me.

Also i have a link like this to click -

<a href="/configAction.do?actionToCall=initSingleConfig&amp;configName=CUSTOM_SCRIPT&ascending=false&configType=User"><img width="30" hspace="5" height="30" border="0" align="absmiddle" src="images/script.png"/>Custom Script </a>

                                                    And

<a href="/configAction.do?actionToCall=initSingleConfig&amp;configName=CUSTOM_SCRIPT&ascending=false&configType=Computer"><img width="30" hspace="5" height="30" border="0" align="absmiddle" src="images/script.png"/>Custom Script </a>

Both having the same link text.  So i have to segregate these links by their urls.  But dont know how to click the link with urls having "?" and "&"


I also want to know how to debug this watij script.  I am using "launchWatijBeanShell.bat" script to start my bean shell.  please help.

Thanks and Kind Regards
jerald




2009/12/16 Darrell Grainger <darrell....@gmail.com>

Darrell Grainger

unread,
Dec 17, 2009, 8:16:41 AM12/17/09
to wa...@googlegroups.com
I think there is something missing in your post. I can find and click
on links using the url even when the link has question marks and
ampersands in it. What I typically do to get information from the web
page is use Firefox and the Firebug plug in. Occasionally, I have
found what I expected to be on the web page was slightly different
than what was on the web page. I'd open the page using Firefox, open
Firebug to examine the DOM, find the link then cut and paste the url
from the actual, rendered web page to my Watij source.

Additionally, if the url does not work for you you might want to
consider using the xpath. Normally I'd use something like:

ie.link(xpath, "//A[text()='Alerts']");

but if there are multiple links with the text 'Alerts', this will not
work. In those cases, I go up the tree until I find an id attribute.
For example, if the HTML is:

<TABLE id="alerts">
<TR>
<TD><A HREF="something.do?p=4&q=8">Alerts</A></TD>
</TR>
</TABLE>

I can use the xpath:

ie.link(xpath, "//TABLE[@id='alerts']/TBODY/TR[1]/TD/A[text()='Alerts']");

Darrell


2009/12/17 Jerald paul <paulj...@gmail.com>:

Jerald paul

unread,
Dec 17, 2009, 8:50:57 AM12/17/09
to wa...@googlegroups.com
Dear Darrell,

Thanks for your mail.  I will definitely try this xpath option. But i sure that this "?" and "&" wont work for me.  As i have just copy pasted the url using firebug.  Also i find that firebug add & -> &amp;  i have noticed this change also and i keenly edited this to &amp; ->  & .  I am unlucky in this "clikcing a url which differ in parameters and same in link text".

I will do reply you when i succeed using xpath.  Just now reading how to use xpath.  May be i can succeed i n this option.

Thank you for your timely help.


Thanks and Kind Regards
jerald




2009/12/17 Darrell Grainger <darrell....@gmail.com>

Jerald paul

unread,
Dec 17, 2009, 8:54:10 AM12/17/09
to wa...@googlegroups.com
Hello Darrell/friends,

Also please let me know is there any option to debug the script or see the log file?  and how to get/generate reports on this automation.  I did not use any junit or some thing.  I totally depend on BeanShell and i love it.


Thanks and Kind Regards
jerald




2009/12/17 Jerald paul <paulj...@gmail.com>

Darrell Grainger

unread,
Dec 17, 2009, 9:12:36 AM12/17/09
to wa...@googlegroups.com
If I understand you correctly, the url in Firebug has &amp; in place
of the & and you edit the url. You should be able to copy and paste
the url from Firebug without editing it. If the url has &amp; then
leave it as &amp;. It is not Firebug doing this. This is what is
ACTUALLY getting rendered.

As for options to debug the script, switch to using an IDE. The bean
shell is good for some quick and dirty testing but for serious
development you need the tools of an IDE like Eclipse, IntelliJ,
NetBeans, etc.

Jerald paul

unread,
Dec 17, 2009, 9:34:07 AM12/17/09
to wa...@googlegroups.com
Dear Darrell,

I am using xpath, and it kills my intrest.  I saved the html source that rendered by the servlet from both ie and firefox.  I found so many difference in the actual html. 

Think xpath that i found - //div[@id="listview"]/table[2]/tbody/tr/td[1]/table/tbody/tr/td/table/tbody/tr[1]/td[1]/a

only works with firefox source and not with ie.

Thanks to XPath checker addon i ff.  It really helped me to get this xpath. Anyway its time to move to an ide.

I have used netbeans. and i know some java.  I will try your suggestion of using an IDE (netbeans).

Darrell Grainger

unread,
Dec 17, 2009, 9:51:49 AM12/17/09
to wa...@googlegroups.com
Sounds like the code is rendering different pages for different
browsers. If this is true then you need to test in all supported
browsers. Otherwise, things might be okay in one browser but not the
other. I'm actually switching away from Watij (and using Selenium-RC)
because it only supports IE.

Jerald paul

unread,
Dec 17, 2009, 9:55:05 AM12/17/09
to wa...@googlegroups.com
Dear Darrell,

Just now i found that ff generates tbody in its own implementation.  and ie does not do that.  So i cannot use this xpath option for finding the correct link.  Anyway i will try to achieve this. 

I have added a project in netbeans and added all the jars files of watij. 

What i have to add as source? Don't know how to proceed. please help


Thanks and Kind Regards
jerald




Darrell Grainger

unread,
Dec 17, 2009, 10:02:16 AM12/17/09
to wa...@googlegroups.com
I don't know the details for NetBeans as I've been using Eclipse for 3
years now. The general concept is:

- Create a project
- Import the Watij libraries (everything in the lib directory plus the
watij.jar)
- Create a jUnit TestCase

I just use the pre-built libraries. If you want to step into the Watij
source you can add the Watij src libraries to the source path of the
project.

Jerald paul

unread,
Dec 17, 2009, 10:12:23 AM12/17/09
to wa...@googlegroups.com
Dear Darrell,

I googled for "Selenium-RC" and .  is it open source? I am the guy responsible for testing our company's product.  I am just a beginner.  I love automated testing. Since i initiate this process of automation testing, i am in search of open source tools. When i find this watij, i feel happy and i had automated some test cases with this beanShell.  If this "Selenium-RC" would help me, i try this also. 

please let me know whether this "Selenium-RC"  is a open source?
Reply all
Reply to author
Forward
0 new messages