David Barishev
David Barishev

Reputation: 544

How to perform a click on a href with javascript function with nightmare


I wanted to know how can i click a button with nightmare with this attributes .

<a class="auth_button leftbtn" href="javascript:SubmitAuthCode( 'enter a friendly name here' );">
        <h3>Submit</h3>
        <h5>my special access code</h5>
</a>

I tried to use the click() method like this :

 .click('.auth_button leftbtn');

But it just doesn't click it( Probably because its not a "real" button - might be wrong)
Any ideas why?Or how should i do it instead

I may found out why the .click() doesn't work:

<div class="modal_buttons" id="auth_buttonsets">
    <div class="auth_buttonset" id="auth_buttonset_entercode" style="display: none;">
            <a class="auth_button leftbtn" href="javascript:SubmitAuthCode( 'enter a friendly name here' );">
                <h3>Submit</h3>
                <h5>my special access code</h5>
            </a>
            <a class="auth_button" href="javascript:SetEmailAuthModalState( 'checkspam' );">
                <h3>What message?</h3>
                <h5>I don't have any message from Steam Support...</h5>
            </a>
            <div style="clear: left;"></div>
    </div>
    <div class="auth_buttonset" id="auth_buttonset_checkspam" style="display: none;">
            <a class="auth_button leftbtn" href="javascript:SubmitAuthCode( 'enter a friendly name here' );">
                <h3>Found it!</h3>
                <h5>and I've entered my special access code above</h5>
            </a>
            <a class="auth_button" href="javascript:SetEmailAuthModalState( 'help' );">
                <h3>No luck still...</h3>
                <h5>I don't have any message from Steam Support...</h5>
            </a>
            <div style="clear: left;"></div>
    </div>
</div>

The button i'm aiming at is in the the div id=auth_buttonset_entercodebecause there are multiple buttons with the same id , but not in the same div . Now i dont know how to select the div and then the class at the same selector.

Upvotes: 2

Views: 1276

Answers (1)

meskobalazs
meskobalazs

Reputation: 16041

Change it to

.click('#auth_buttonset_entercode .auth_button.leftbtn');

So it will select the element with both classes.

Upvotes: 2

Related Questions