Nightwatch - 在导航栏中抓取嵌套按钮

Nightwatch - grabbing a nested button in a nav-bar

我目前正在为我的网站做一些自动化测试,其中我需要通过使用 Nightwatch 中的 click() 方法使用 css 选择器抓住一个按钮硒服务器。

我的导航栏是这样的:

main nav -> nav navbar-nav navbar-right -> dropdown (two of these - I need the second) -> dropdown-toggle (this is the button that needs to be pressed).

我试过让选择器通过,以及使用第 nth-child 来获取第二个,但事实证明这很棘手。我当前的代码如下:

browser
    .waitForElementVisible('body')  
    .click("ul.nav.navbar-right > li.dropdown:last > a")

:last 不是有效的 CSS 选择器,您可能打算使用 :last-child.

旁注:因为你知道你(总是)想点击第二个下拉菜单,我个人更喜欢在我的测试中尽可能冗长,所以我也会考虑使用 :nth-child(2).