-2

I have tried :parent, but it did not work:

Eg:

card-paragraph-textbox.blue-highlight :parent .edit-Text

Class Name of child: card-paragraph-textbox.blue-highlight.

Class Name of parent: .edit-Text.

Keyword: :parent

Please help on this!!

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
XXX
  • 11
  • 1
  • 3
  • I don't know Selenium, but it's not possible using CSS alone. See [Is there a CSS parent selector?](https://stackoverflow.com/q/1014861/1016716) – Mr Lister Nov 28 '17 at 10:02
  • 1
    There are atleast 5 ways of accessing elements in Selenium. What all attempts have you failed at? Share the code.. – absin Nov 28 '17 at 10:03
  • I just tried the above mentioned syntax childClass : parent – XXX Nov 28 '17 at 10:13
  • Welcome to Stack Overflow! Please read [ask], especially the part about [mcve] (MCVE), and [How much research effort is expected?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) This will help you debug your own programs and solve problems for yourself. If you do this and are still stuck you can come back and post your MCVE, what you tried, and the execution result including any error messages so we can better help you. Also provide a link to the page and/or the relevant HTML. – JeffC Nov 28 '17 at 15:08
  • @XXX, was my answer helpful? If yes -- check a tick near my answer, please. – Ratmir Asanov Nov 29 '17 at 09:01

1 Answers1

2

There is no way, use XPath instead.

Get parent:

//*[@class='edit-Text']

Get parent via child:

//*[@class='card-paragraph-textbox blue-highlight']/..

or

//*[@class='card-paragraph-textbox blue-highlight']/parent::*
Marcel
  • 1,443
  • 2
  • 14
  • 24