Monkomatic has asked for the wisdom of the Perl Monks concerning the following question:

UNABLE TO CLICK ON SELENIUM ELEMENT

Hi All,

Im running into a simple problem with selenium perl clicking an image with no name value or ID. I have tried everything i could think of and included the trys below.

I need to click the following image. Yet i can find no way to do it. https://images.com/images/G/01/x-locale/common/transparent-pixel._V192234675_.gif

Page code is:

<td colspan="2" class="add-instrument-container"> <input title="" alt="add your card" class="payselectButtonsSprite s_ad +d-your-card add-instrument-button action_link" id="" value="" name="" + src="https://images.com/images/G/01/x-locale/common/transparent-pixe +l._V192234675_.gif" ref="ox_pay_page_cc_add" type="image" border="0"> + <img class="loading-small" src="https://images.com/im +ages/G/01/x-locale/common/loading/loading-small._V192239831_.gif" alt +=""> </td> </tr>

Have tried

@addcardsplit1 = split(/add-instrument-container/i, $pagesource);

@addcardsplit2 = split(/https:\/\//i, @addcardsplit11);

@addcardsplit3 = split(/gif/i, @addcardsplit21);

$addcardlink=@addcardsplit3[0];

#print "Addcardlink:$addcardlink \n";$addcardlink= "http" . $addcardlink . "gif";

$addcardlink= $addcardlink . "gif";

print "Addcardlink:$addcardlink \n";

#$sel->click("link=$addcardlink");

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

#$sel->click("css=inputsrc=$addcardlink");

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

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

#$sel->click("css=inputsrc=$addcardlink");

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

#$sel->click("dom=document.images21");

#$sel->click("dom=document.images22");

#$sel->click("dom=document.images23");

#$sel->click("dom=document.images24");

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

    Hi there;

    There's no need to yell! It's actually easier for us to read the title of your post if it's not all in capital letters.

    Second, could you do us a favour of giving us a working self-contained code snippet in <c></c> tags? Right now your code is very difficult to read, and there's no way we could hope to reproduce your issue in order to help you.

    Thanks!

    Anne

      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

        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