david hol
david hol

Reputation: 1280

Why Selenium not recognised class with space in the name using CSS?

I want to fine this WebElement:

<div class="title_bar bar ng-sss" ng-rr="!isBulkMode">

So when using CSS:

div[class=title_bar bar ng-sss]

This element could not found.

And with Xpath this works:

//div[@class='title_bar bar ng-sss']

Upvotes: 1

Views: 3483

Answers (1)

Guy
Guy

Reputation: 50919

You don't have apostrophes in the cssSelector

By.cssSelector("div[class=`title_bar bar ng-sss`]");

You also don't have to use square brackets when using cssSelector

By.cssSelector("div.title_bar.bar.ng-sss`]");
// or
By.cssSelector(".title_bar.bar.ng-sss`]");

Dot before the name represents class name.

Upvotes: 2

Related Questions