swapfile
swapfile

Reputation: 417

Selector with changing Form IDs

i have a little Problem with Selection this Input form an the Submit Button within Casperjs.

<div id="id1d9" style="display:none"></div>
    <div class="item wishname" id="id1da">
    <!-- <div class="item wishname">-->
    <label id="id1db" for="id1a0">
        E-Mail-Wunschname
    </label>

    <div class="input" id="id1a1">
        <input class="wishname feedback-panel-trigger multiReplaceCharsInWishnamelField" autocomplete="off" maxlength="40" value="" name="wishnamePanel:wishname:subForm:alias" id="id1a0" type="text">

            <span class="btn-positioner">
                <span class="btn-wrapper btn-m btn-key">
                    <input name="wishnamePanel:wishname:subForm:checkAvailability" id="checkAvailabilityBtn" value="Prüfen" type="submit">
                </span>
            </span>

The main Problem is, that the id's for the divs changes on every reload randomized. so casperjs like ==>

this.sendKeys('#id1a0 ',"Test String");

doesn't work.

Upvotes: 0

Views: 43

Answers (1)

rubentd
rubentd

Reputation: 1275

Since the id always changes, you should use an alternate selector to target this element. You can use classes, tag names or combinations thereof.

What about this:

.wishname.feedback-panel-trigger.multiReplaceCharsInWishnamelField

or this:

.item.wishname > .input > input

If you have multiple items with the same classes you can try to iterate to get the right one.

Upvotes: 3

Related Questions