How to capture a tag in same level using Sibling “+” Operator CSS Selector in Selenium.

Problem scenario

I want to capture this input tag, located in div tag, but in the same level of span.

How to do it ?

First of all capture the div that span tag is under for that use below CSS locator.

Then using divTag element can capture the input that in the same level.

Syntax for it is +.

locator 1+ locator 2

So here to for locator one I captured using class name and locator 2 is using input tag.

Full code is as per below.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store