Bastian
Bastian

Reputation: 1237

How to change xpath to css in selenium

I am having an issue in selenium. I have this xpath that is working well

//*[@id='info_country']//div[contains(@class,'ant-select-selection-selected-value')

and I try to change it and use css selector instead of xpath I write this code:

#info_country .ant-select-selection-selected-value ng-tns-c17-151 ng-star-inserted

and the consul not find the path

can someone advise this is the consul and I pointed the element I want to locate

enter image description here

Upvotes: 0

Views: 311

Answers (1)

Guy
Guy

Reputation: 50809

ng-tns-c17-151 and ng-star-inserted are separate classes, you need to state it in the selector using .. Currently, the selector treats ng-tns-c17-151 and ng-star-inserted as tags

#info_country .ant-select-selection-selected-value.ng-tns-c17-151.ng-star-inserted

The direct translation will be without those classes

#info_country .ant-select-selection-selected-value

Upvotes: 1

Related Questions