user2743416
user2743416

Reputation: 79

Selenium element identifier by using css selector?

I am new to selenium I'm not able to find the "<a class="standalone clearfix" href="/logout">Sign out</a>" element, I tried by the following css identifier to find "sign out" button

css= div[class='sub-nav chat-bubble']>ul>div:nth-child(3)>li:nth-child(4)>a

Can you please modify it.

<div class="sub-nav chat-bubble">
<div class="name">Manju Nath</div>
<ul style="background-color: transparent;">
<div class="email force-no-break" style="background-color: transparent;">
<div class="subheader-gray-text">243.3 KB of 2 GB used</div>
<div class="quota_graph_container" style="background-color: rgb(238, 238, 238);">
<li class="first-standalone">
<a class="standalone clearfix" target="_blank" href="/account">Settings</a>
</li>
<li>
<a class="standalone clearfix" href="/install">Install</a>
</li>
<li>
<a class="standalone clearfix" target="_blank" href="/plans">Upgrade</a>
</li>
<li>
<a class="standalone clearfix" href="/logout">Sign out</a>
</li>
</ul>
<div class="chat-bubble-arrow-border"></div>
<div class="chat-bubble-arrow"></div>
</div>

Upvotes: 0

Views: 320

Answers (2)

Amith
Amith

Reputation: 7008

I agree with user1177636. I would try using selectors which is ofcourse unique as well as simple or readable,

css = a[href='/logout']

Upvotes: 0

Jitendra Khushwaha
Jitendra Khushwaha

Reputation: 11

Use Xpath instead

you can simply findout the xpath of an element by browsers inspect element tool

find_element_by_xpath("//div[@class='quota_graph_container']/li[4]/a")

OR

css= div[class='quota_graph_container']>li:nth-child(4)>a

Upvotes: 1

Related Questions