Adrija
Adrija

Reputation: 99

Need to find the Css-selector path

I have the path in the HTML style:

    <div class="BaseL">
        <ul class="list">
            <li draggable="true" class="listEntry" id="ItemList.item.0" widgetid="ItemL.item.0" >

The code that I have used is: driver.findbyElement(By.cssSeelector(".BaseL.list.item.0"))

Its not able to find it by id, tried webdriver.wait (didn't work). But even the cssSelector isnt working, can anyone please help me to find the cssSelector? Thanks.

Upvotes: 0

Views: 4203

Answers (3)

IPolnik
IPolnik

Reputation: 649

If you want to find your element by Id:

driver.findbyElement(By.cssSelector(".ItemList.item.0"));

by Class:

driver.findbyElement(By.className("#listEntry"));

Upvotes: 1

undetected Selenium
undetected Selenium

Reputation: 193068

You can use either of the following :

"div.BaseL>ul.list>li.listEntry[id^='ItemList'][widgetid$='0']"

PS: As it is a draggable element you have to induce WebDriverWait

Upvotes: 0

supputuri
supputuri

Reputation: 14135

Here is the correct CSS.

You have to mask the . in the li id with \

.BaseL .list  #ItemList\.item\.0

enter image description here

Upvotes: 0

Related Questions