0

I'm good at writing XPATH locators but for my new project i have to write locators using CSS

i have 2 doubts

1)

enter image description here

from the above code i have to identify div with id contains value "col3"

in xpath i can write //div[contains(@id,'col3')]

in css i tried below locators

css=#id:contains('col3')

css=div:contains(#id,'col3') but none of them working.

please help me with CSS locator to identify id contains value "col3"

2)

enter image description here

i have to navigate from one attribute to its parent attribute.

i.e., from "Form tag i have to navigate ti its parent div tag"

in XPATH //form[@id='comment-form']/../

help me to navigate using CSS

BoltClock
  • 630,065
  • 150
  • 1,295
  • 1,284
Sid
  • 615
  • 1
  • 7
  • 18

2 Answers2

0

Can you try this for 1st one css=div[id*='col3']

Akhil K
  • 101
  • 3
0

The solution to your first problem is:

div[id*='col3'] 

Referring to Is there a CSS parent selector?, I do not think there is any solution for your 2nd problem. You might have to use xpath here.

Community
  • 1
  • 1
Nitesh
  • 159
  • 7