0

The below code goes to a page, finds the dropdown menu and clicks the first one in the list. How do I adjust the following code to be able to select the second or third item in the list?

await browser
       .findElement(By.css('#historyTabDropdown ul>li>a'))
       .then(e => e.click());

1 Answer 1

1

Try using css selector nth-child. The css is li:nth-child(2)

await browser
       .findElement(By.css('#historyTabDropdown ul>li:nth-child(2)>a'))
       .then(e => e.click());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.