user2325313
user2325313

Reputation: 99

How to click on a hyperlink using CasperJS?

<div class="company-list-title"> … </div>
<ul id="company-list1" class="company-list">
    <li class="company-list-item"> … </li>
    <li class="company-list-item"> … </li>
    <li class="company-list-item"> … </li>
    <li class="company-list-item">
        <a class="company_link" href="javascript: applyswitch('1006084861', '1006084864')">

            E2E C2 Harmony US Plus_US_QBP-T39_1_201309161379373407264 (cluster 2: company 1006084861)

        </a>

How to click on hyperlink with text "E2E C2 Harmony US Plus_US_QBP-T39_1_201309161379373407264 (cluster 2: company 1006084861)" using CasperJS?

Following code does not work:

casper.then(function() {  
this.test.assertExists({  
            type: 'xpath',  
            path: '//ul[@class="company-list"]'  
    }, "Got Here 1");  
    this.test.assertExists({   
            type: 'xpath',  
            path: '//ul[@class="company-list"]//a[text()="E2E C2 Harmony US Plus_US_QBP-  T39_1_201309161379373407264 (cluster 2: company 1006084861)"]'  
    }, "Got Here 2");  
    this.click(('//ul[@class="company-list"]//a[text()="E2E C2 Harmony US Plus_US_QBP-  T39_1_201309161379373407264 (cluster 2: company 1006084861)"]'), function() {  
    console.log("Woop!");  
});  
});  

Upvotes: 0

Views: 1136

Answers (1)

Felix
Felix

Reputation: 38102

You can try to use clickLabel():

this.clickLabel('E2E C2 Harmony US Plus_US_QBP-T39_1_201309161379373407264 (cluster 2: company 1006084861)', 'a');

Upvotes: 1

Related Questions