adspace


How can we move to nth child element using css selector?

Answer Posted / Sanjay Varshney

To select the nth child element using CSS Selector in Selenium, you can use the `:nth-child()` pseudo-class. Here's an example:

```python
from selenium import webdriver

# Assuming 'parent_element' is the parent element and 'n' is the nth child index
child_element = driver.find_element_by_css_selector(f"{parent_element} > div:nth-child({n})")
```

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what will be the first salary and what will be the hike in the salary?

929


How can you fetch an attribute from an element? How to retrieve typed text from a textbox?

1197


What’s selenese?

920


Have you created any framework?

1039


Do you know how to locate a link using its text in selenium?

986