J
J
JIvanov2015-03-09 16:52:46
selenium
JIvanov, 2015-03-09 16:52:46

How to find the desired element on the page?

Good afternoon.
There is this piece on the page:
General
Friends 311
Photos 210
Groups 14
Games 0
With the following code:

<div id="hook_Block_MiddleColumnTopCard_MenuFriend" class="hookBlock"><div class="mctc_navMenu ">
<a hrefattrs="st.cmd=friendMain&amp;st.friendId=1111111&amp;st._aid=NavMenu_Friend_Main" href="/profile/1111111" class="mctc_navMenuSec">Основное</a>
<a hrefattrs="st.cmd=friendFriend&amp;st.friendId=1111111&amp;st._aid=NavMenu_Friend_Friends" href="/profile/1111111/friends" class="mctc_navMenuSec">Друзья&nbsp;<span class="navMenuCount">311</span></a>
<a hrefattrs="st.cmd=friendPhotos&amp;st.friendId=1111111&amp;st._aid=NavMenu_Friend_Photos" href="/profile/1111111/photos" class="mctc_navMenuSec mctc_navMenuActiveSec">Фото&nbsp;<span class="navMenuCount">210</span></a>
<a hrefattrs="st.cmd=friendAltGroup&amp;st.friendId=1111111&amp;st._aid=NavMenu_Friend_AltGroups" href="/profile/1111111/groups" class="mctc_navMenuSec">Группы&nbsp;<span class="navMenuCount">14</span></a>
<a hrefattrs="st.cmd=friendApps&amp;st.friendId=1111111&amp;st._aid=NavMenu_Friend_Apps" href="/profile/1111111/games" class="mctc_navMenuSec">Игры&nbsp;<span class="navMenuCount">0</span></a>

Which Selenium method will be more correct and faster to find the value: 210 (the fourth line from the top is "photo")? If possible with a code example. (preferably in Python :)) Many thanks in advance!!!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
JIvanov, 2015-03-10
@JIvanov

more than 2000 views ..... and silence ......

K
Kenshir007, 2015-08-21
@Kenshir007

Try:
driver.findElement.byCSSSelector("a[href*='photos']")
I already forgot how in Python, but I think the meaning is clear
In Java, I would
write @FindBy(css="a[href*='members ']") private WebElement navMenuPhotos;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question