[Webtest] How to click an image link?
Marc Guillemot
webtest@lists.canoo.com
Tue, 12 Jul 2005 13:32:11 +0200
The xpath is evaluated against the DOM which itself is the result of the parsing therefore some changes are performed to
the source html code like for instance changing attribute names to lowercase.
Try:
<click description="Click the 'Show Chart' tab"
xpath="//img[@onclick="loadPage('/edgedynamics/portal/jsp/analytics/explorer_chart.jsp');"]"
/>
Marc.
Tim Miller wrote:
> This seems close to working. I changed the syntax slightly to add the
> missing “]” and quotes so I have the following:
>
>
>
> <click description="Click the 'Show Chart' tab"
>
>
> xpath="//img[@ONCLICK="loadPage('/edgedynamics/portal/jsp/analytics/explorer_chart.jsp');"]"
> />
>
>
>
> But, the button cannot be found.
>
>
>
> com.canoo.webtest.engine.StepFailedException: No element found with
> xpath
> "//img[@ONCLICK="loadPage('/edgedynamics/portal/jsp/analytics/explorer_chart.jsp');"]".,
> Step: Click at
> file:C:/home/qauser01/ApplicationTests/Suite-p2.4-a2.3.2/gm-test/Analytics/VerifyViewTest.xml:73:
> with (stepid="<unknown>",
> XPath="//img[@ONCLICK="loadPage('/edgedynamics/portal/jsp/analytics/explorer_chart.jsp');"]",
> stepType="click")
>
>
>
>
>
>
>
> Regards,
>
> Tim
>
>
>
>
>
> ------------------------------------------------------------------------
>
> *From:* webtest-admin@lists.canoo.com
> [mailto:webtest-admin@lists.canoo.com] *On Behalf Of *Nimesh Muley
> *Sent:* Thursday, July 07, 2005 9:46 PM
> *To:* webtest@lists.canoo.com
> *Subject:* RE: [Webtest] How to click an image link?
>
>
>
> Hi,
>
>
>
> We had a similar requirement in one of our projects and following was
> the solution for the same.
>
>
>
> Use the <click> step. For the image use XPATH expression.
>
> E.g. in your case it would be
>
> <click
> xpath="//img[@onclick=loadPage('/edgedynamics/portal/jsp/analytics/explorer_chart.jsp');"
> stepid="View the chart"/>
>
>
>
> The onclick attribute is used to locate the image in the example above.
> Similarly I believe you can use other attributes instead of onclick
> attribute.
>
>
>
> Regards,
>
> - Nimesh
>
> -----Original Message-----
> *From:* Tim Miller [mailto:tmiller@edgedynamics.com]
> *Sent:* Friday, July 08, 2005 12:30 AM
> *To:* webtest@lists.canoo.com
> *Subject:* [Webtest] How to click an image link?
>
> Is there a way to click an image so the onclick event is triggered with WebTest? Html follows.
>
>
>
>
>
> <td>
>
> <img name="chart" src="/edgedynamics/portal/images/chart_off.gif"
>
> border="0"
>
> ONMOUSEOVER="showOnButton('chart');"
>
> ONMOUSEOUT="showOffButton('chart');"
>
> ONCLICK="loadPage('/edgedynamics/portal/jsp/analytics/explorer_chart.jsp');">
>
> </td>
>
>
>
>
>
> Thanks,
>
> Tim
>
>
>
>
>
> (This email message is for the sole use of the intended recipient(s)
> and may contain confidential information. Any unauthorized review,
> use, disclosure or distribution is prohibited. If you are not the
> intended recipient, please contact the sender by reply email and
> destroy all copies of the original message.)
>
>
>
>
>
> MASTEK
> "Making a valuable difference"
> Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.
> In the US, we're called MAJESCO
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Opinions expressed in this e-mail are those of the individual and not
> that of Mastek Limited, unless specifically indicated to that effect.
> Mastek Limited does not accept any responsibility or liability for it.
> This e-mail and attachments (if any) transmitted with it are
> confidential and/or privileged and solely for the use of the intended
> person or entity to which it is addressed. Any review, re-transmission,
> dissemination or other use of or taking of any action in reliance upon
> this information by persons or entities other than the intended
> recipient is prohibited. This e-mail and its attachments have been
> scanned for the presence of computer viruses. It is the responsibility
> of the recipient to run the virus check on e-mails and attachments
> before opening them. If you have received this e-mail in error, kindly
> delete this e-mail from all computers.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>