0

In the below code i want "or" "and" operator in the value field so that i dont have to write a new step everytime if i found diff css-selectors pointing to same location. And thanks in Advance

{
  "name": "cardAccount.accountHolder",
  "locator": {
      "locatorType": "BY_CSSSELECTOR",
      "value": "#login>div>b || #login>span"

  }
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Sameer
  • 1
  • Related, but not a duplicate because of the context in which this answer is in: http://stackoverflow.com/questions/2263975/jquery-or-selector/2263976#2263976 – Daniel A. White Jul 20 '14 at 10:37

2 Answers2

2

Use a comma, it is like a strict OR, not an exclusive OR.

#login>div>b, #login>span

AND doesn't really work except by just being more explicit with the selector.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
0

Like Daniel A. White said the comma is an implicit OR operator. It can only be used at the highest level meaning you can only concatenate two or more full selectors using the comma. Something like this XPath expression //*[@class or @id] cannot be achieved with CSS selectors.

The AND operator is implicit. If you want a div to have class1 and class2 you write div.class1.class2. This means that AND only works on a single level. If you want to have

.class1 > .class3 AND .class2 > .class3

then you would get .class1.class2 > .class3.

But what would it mean to have .class1 > .class3 AND .class2 > .class4? It is entirely ambiguous and cannot be solved with CSS selectors, because it doesn't make sense.

Community
  • 1
  • 1
Artjom B.
  • 61,146
  • 24
  • 125
  • 222