Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: UNABLE TO CLICK ON SELENIUM ELEMENT

by Monkomatic (Sexton)
on Oct 18, 2011 at 08:45 UTC ( [id://932093]=note: print w/replies, xml ) Need Help??


in reply to Re: UNABLE TO CLICK ON SELENIUM ELEMENT
in thread UNABLE TO CLICK ON SELENIUM ELEMENT

i wish it was clearer but you can see cleaner code by clicking on the download link.

I tried to keep the question as small as possible is why there is not more

Replies are listed 'Best First'.
Re^3: UNABLE TO CLICK ON SELENIUM ELEMENT
by anneli (Pilgrim) on Oct 18, 2011 at 09:03 UTC

    On the HTML, yes, but not your actual Perl code. Have you even looked at your own submission!? It contains the following text:

    #$sel->click("xpath=//divclass='payselectButtonsSprite s_add-your-card add-instrument-button action_link'");

    This is surely not what you intended (it's invalid XPath, and there's a link to a node in the middle of it).

    A short, self contained, correct example is doing a courtesy to those who might volunteer their time.

    There's more than one Selenium module on CPAN; you haven't told us which one you're using.

    The core of your question is to do with Selenium RC, not Perl. Maybe someone here will happen to know the answer, but you'd have more luck on a Selenium mailing list or similar.

    Finally, using an XPath query is the way to go about this. I'd love to try to help, but a) you haven't posted the full HTML excerpt either (your commented out XPath queries show references to a <div> tag, which is not in the HTML given), so I can't actually write one!, and b) your sample code isn't in <c></c> tags, so I can't use that to try to guess what your HTML does actually have!

    Please: help us help you.

    Anneli

      The full html source code is quite huge.. quite huge... or i would have posted it. I am using selenium 1 to make the requets

      I do realize it is an xpath solution. However all the attempts i have tried have been from the web and selenium has many more flavors than perl so i was never sure my syntax was correct which is why i was asking here for correct perl sytax.

      I am hoping somone knows the correct perl syntax for finding and clicking an image by alt or partial or full image name? Everytime i try to use @ i get an error and if i dont use it it complains the element cannot be found.

      #$sel->click("xpath=//imgcontains($addcardlink)");

      #$sel->click("xpath=//input@src=$addcardlink");

      p.s.<I do appreciate that your trying to help anneli

      #$sel->click("xpath=//divclass='payselectButtonsSprite s_add-your-card add-instrument-button action_link'");

      This is surely not what you intended (it's invalid XPath, and there's a link to a node in the middle of it).

      That is exactly how it appears in the code above. This is what im dealing with. And that node is exactly what i am looking to press. I am thinking of downloading firebug or another gadget to get all elements. Is there a simply was selenium will list all elements or images on a page maybe?

        Okay -- there are pastebin services, however, which might help.

        My point about "this is surely not what you intended" is that the formatting is all wrong. Monkomatic, compare this:

        #$sel->click("xpath=//imgcontains($addcardlink)");

        with this:

        #$sel->click("xpath=//img[contains($addcardlink)]");

        See how part of the XPath query is transformed into a link in the first one? It's because you need to put <c></c> tags around every example you give; otherwise your code can get seriously messed up by the PerlMonks node formatter.

        Have you tried something like $sel->click("xpath=//img[contains(@src, \"$addcardlink\")]");? You might be getting the syntax error because $addcardlink is expanding the URL in place, but it may need to be quoted.

        Selenium's wiki has more information on using XPath queries to locate elements.

        Anne

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://932093]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-03-28 18:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found