如何使用queryselector初始化链接

时间:2015-04-21 10:43:38

标签: java jquery

我想点击第二个链接

<ul id="library_list" class="side-menu" style="height: 358px;">
    <li class="side-menu-section selected-section">
        <a class="side-menu-section-link qa-group-id-undefined open" href="#">First Link</a>
    </li>
       <li class="side-menu-section">
            <a class="side-menu-section-link qa-group-id-undefined" href="#">Second Link</a>    
    </li>
</ul>

我通过执行以下代码

得到了异常
pageUrls.QuerySelector('side-menu-section a[text="SecondLink"]')).Click()

你能帮忙解决这个问题。

1 个答案:

答案 0 :(得分:0)

我认为你的选择器不正确......

&#13;
&#13;
console.log(document.querySelector('.side-menu-section:last-child a'));
&#13;
<ul id="library_list" class="side-menu" style="height: 358px;">
    <li class="side-menu-section selected-section">
        <a class="side-menu-section-link qa-group-id-undefined open" href="#">First Link</a>
    </li>
       <li class="side-menu-section">
            <a class="side-menu-section-link qa-group-id-undefined" href="#">Second Link</a>

    </li>
</ul>
&#13;
&#13;
&#13;